From 5849a89be72919068177e2830142c600a0bb7aeb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 18:29:33 +0000 Subject: [PATCH 01/39] chore(internal): update `actions/checkout` version --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6386acf8..bd17f562d 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 From 551d3d983edbc2dd99c0143b2779146fa00ae80f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:44:28 +0000 Subject: [PATCH 02/39] feat(client): add `ToString` to `ApiEnum` --- src/Orb/Core/ApiEnum.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Orb/Core/ApiEnum.cs b/src/Orb/Core/ApiEnum.cs index 32b85f268..0d74d005b 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; From 79d34710f779ca309e84faddc3e28bfa5b9c73bc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 21:03:33 +0000 Subject: [PATCH 03/39] chore(internal): simplify imports --- .../Alerts/AlertCreateForCustomerParams.cs | 2 +- .../Beta/BetaCreatePlanVersionParams.cs | 1219 +++--- .../ExternalPlanIDCreatePlanVersionParams.cs | 3380 ++++++----------- src/Orb/Models/Beta/PlanVersionPhase.cs | 36 +- src/Orb/Models/Coupons/CouponCreateParams.cs | 25 +- .../CreditBlockRetrieveResponse.cs | 126 +- .../CreditNotes/CreditNoteCreateParams.cs | 67 +- .../BalanceTransactionCreateParams.cs | 2 +- .../BalanceTransactionCreateResponse.cs | 121 +- .../Customers/Credits/CreditListResponse.cs | 110 +- .../Credits/Ledger/LedgerCreateEntryParams.cs | 82 +- .../Models/Customers/CustomerCreateParams.cs | 27 +- .../Backfills/BackfillCreateResponse.cs | 36 +- src/Orb/Models/Events/Volume/EventVolumes.cs | 35 +- .../InvoiceLineItemCreateResponse.cs | 74 +- .../Models/Invoices/InvoiceCreateParams.cs | 50 +- .../Invoices/InvoiceFetchUpcomingResponse.cs | 312 +- src/Orb/Models/Invoices/InvoiceListParams.cs | 49 +- src/Orb/Models/Metrics/BillableMetric.cs | 32 +- .../Migrations/MigrationRetrieveResponse.cs | 40 +- src/Orb/Models/Plans/PlanCreateParams.cs | 1180 +++--- src/Orb/Models/Prices/PriceCreateParams.cs | 892 ++--- .../Prices/PriceEvaluateMultipleParams.cs | 263 +- .../SubscriptionChangeListParams.cs | 32 +- .../Models/Subscriptions/DiscountOverride.cs | 32 +- .../Subscriptions/NewSubscriptionBulkPrice.cs | 20 +- .../NewSubscriptionBulkWithProrationPrice.cs | 26 +- ...wSubscriptionCumulativeGroupedBulkPrice.cs | 56 +- .../NewSubscriptionGroupedAllocationPrice.cs | 26 +- ...ewSubscriptionGroupedTieredPackagePrice.cs | 56 +- .../NewSubscriptionGroupedTieredPrice.cs | 64 +- ...scriptionGroupedWithMeteredMinimumPrice.cs | 81 +- ...criptionGroupedWithProratedMinimumPrice.cs | 22 +- ...wSubscriptionMatrixWithDisplayNamePrice.cs | 54 +- ...wSubscriptionMaxGroupTieredPackagePrice.cs | 56 +- .../NewSubscriptionMinimumCompositePrice.cs | 26 +- ...wSubscriptionPackageWithAllocationPrice.cs | 24 +- ...ionScalableMatrixWithTieredPricingPrice.cs | 86 +- ...ptionScalableMatrixWithUnitPricingPrice.cs | 49 +- ...ewSubscriptionThresholdTotalAmountPrice.cs | 58 +- .../NewSubscriptionTieredPackagePrice.cs | 64 +- ...bscriptionTieredPackageWithMinimumPrice.cs | 52 +- .../NewSubscriptionTieredWithMinimumPrice.cs | 65 +- .../NewSubscriptionUnitWithPercentPrice.cs | 28 +- .../NewSubscriptionUnitWithProrationPrice.cs | 26 +- .../Subscriptions/SubscriptionCreateParams.cs | 1322 +++---- .../Subscriptions/SubscriptionListParams.cs | 32 +- .../SubscriptionPriceIntervalsParams.cs | 61 +- .../Services/Coupons/ISubscriptionService.cs | 14 +- .../Services/Coupons/SubscriptionService.cs | 27 +- 50 files changed, 3932 insertions(+), 6687 deletions(-) diff --git a/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs index 6fb70fe86..ff4f81781 100644 --- a/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs +++ b/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs @@ -159,7 +159,7 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt /// /// 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/Beta/BetaCreatePlanVersionParams.cs b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs index 147e0d65b..fa8856ae7 100644 --- a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs @@ -260,12 +260,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 +315,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 +614,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 +649,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 +663,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 +790,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 +837,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 +890,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; @@ -1465,7 +1459,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 +1525,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 +1561,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 +1603,13 @@ public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = nul this._element = element; } - public Price( - global::Orb.Models.Beta.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public Price(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Beta.Minimum value, JsonElement? element = null) + public Price(Minimum value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1633,13 +1621,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 +1703,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 +1950,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 +2086,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 +2247,45 @@ 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; + value = this.Value as CumulativeGroupedAllocation; 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.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.Minimum` + /// // `value` is of type `Minimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Beta.Minimum? value) + public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) { - value = this.Value as global::Orb.Models.Beta.Minimum; + value = this.Value as Minimum; return value != null; } @@ -2330,45 +2314,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 +2371,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 +2382,24 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.Percent value) => {...}, - /// (global::Orb.Models.Beta.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2426,7 +2408,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 +2419,24 @@ 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 minimum, System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -2468,7 +2450,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 +2483,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 +2501,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 +2522,19 @@ 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: + case 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 +2560,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 +2571,24 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.Percent value) => {...}, - /// (global::Orb.Models.Beta.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2615,7 +2597,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 +2608,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 +2627,11 @@ 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 minimum, System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -2663,7 +2639,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 +2650,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 +2658,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 +2668,82 @@ 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), + Minimum value => minimum(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 Price(NewPlanUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanTieredPrice value) => - new(value); + public static implicit operator Price(NewPlanTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanBulkPrice value) => - new(value); + public static implicit operator Price(NewPlanBulkPrice 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(BulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanPackagePrice value) => - new(value); + public static implicit operator Price(NewPlanPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanMatrixPrice value) => - new(value); + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixWithAllocationPrice 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(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewPlanBulkWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedWithMeteredMinimumPrice 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(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixWithDisplayNamePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanMaxGroupTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator Price(NewPlanScalableMatrixWithUnitPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanCumulativeGroupedBulkPrice 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.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(CumulativeGroupedAllocation 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(Minimum 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 @@ -2880,7 +2799,7 @@ public override void 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 +2813,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 +2904,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3230,11 +3148,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3365,11 +3282,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3525,11 +3441,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3548,10 +3463,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3592,10 +3504,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3614,11 +3523,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3635,40 +3540,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 +3570,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 +3678,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 +3843,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 +3861,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 +3903,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 +3934,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 +3950,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 +3959,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 +4008,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 +4024,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 +4079,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 +4095,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 +4109,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 +4130,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 +4140,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 +4171,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 +4324,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 +4351,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 +4365,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 +4432,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 +4447,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 +4507,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 +4578,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 +4745,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 +4763,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 +4772,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 +4793,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 +4803,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 +4823,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 +4842,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 +4850,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 +4879,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 +4895,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 +4904,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 +4963,7 @@ public override void Validate() public TieredWithProrationConfigTier() { } public TieredWithProrationConfigTier( - global::Orb.Models.Beta.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } @@ -5141,8 +4980,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 +4989,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 +5156,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 +5185,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 +5200,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 +5267,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 +5283,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 +5305,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 +5415,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 +5582,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 +5600,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 +5609,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 +5632,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 +5642,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 +5662,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 +5682,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 +5752,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -5943,8 +5769,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5952,18 +5778,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 +5945,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 +5974,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 +5989,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 +6056,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 +6072,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 +6094,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 +6204,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 +6371,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 +6389,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 +6398,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 +6421,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 +6431,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 +6451,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 +6471,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 +6541,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -6749,8 +6558,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6758,18 +6567,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 +6734,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 +6763,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 +6778,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 +6845,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,12 +6860,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Minimum, - global::Orb.Models.Beta.MinimumFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Minimum : JsonModel { /// @@ -7095,14 +6892,12 @@ public required string ItemID /// /// Configuration for minimum pricing /// - public required global::Orb.Models.Beta.MinimumConfig MinimumConfig + public required MinimumConfig MinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("minimum_config"); } init { this._rawData.Set("minimum_config", value); } } @@ -7354,7 +7149,7 @@ public Minimum() this.ModelType = JsonSerializer.SerializeToElement("minimum"); } - public Minimum(global::Orb.Models.Beta.Minimum minimum) + public Minimum(Minimum minimum) : base(minimum) { } public Minimum(IReadOnlyDictionary rawData) @@ -7372,21 +7167,18 @@ public Minimum(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Minimum FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class MinimumFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Minimum.FromRawUnchecked(rawData); + public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => + Minimum.FromRawUnchecked(rawData); } /// @@ -7451,12 +7243,7 @@ JsonSerializerOptions options /// /// Configuration for minimum pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.MinimumConfig, - global::Orb.Models.Beta.MinimumConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class MinimumConfig : JsonModel { /// @@ -7502,7 +7289,7 @@ public override void Validate() public MinimumConfig() { } - public MinimumConfig(global::Orb.Models.Beta.MinimumConfig minimumConfig) + public MinimumConfig(MinimumConfig minimumConfig) : base(minimumConfig) { } public MinimumConfig(IReadOnlyDictionary rawData) @@ -7518,10 +7305,8 @@ public MinimumConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -7534,12 +7319,11 @@ public MinimumConfig(string minimumAmount) } } -class MinimumConfigFromRaw : IFromRawJson +class MinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.MinimumConfig.FromRawUnchecked(rawData); + public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + MinimumConfig.FromRawUnchecked(rawData); } [JsonConverter(typeof(MinimumConversionRateConfigConverter))] @@ -7826,25 +7610,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Percent, - global::Orb.Models.Beta.PercentFromRaw - >) -)] +[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); } } @@ -7891,14 +7668,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required global::Orb.Models.Beta.PercentConfig PercentConfig + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullClass("percent_config"); } init { this._rawData.Set("percent_config", value); } } @@ -7962,12 +7737,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 PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8124,7 +7899,7 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Percent(global::Orb.Models.Beta.Percent percent) + public Percent(Percent percent) : base(percent) { } public Percent(IReadOnlyDictionary rawData) @@ -8142,27 +7917,24 @@ public Percent(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Percent.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.PercentCadenceConverter))] +[JsonConverter(typeof(PercentCadenceConverter))] public enum PercentCadence { Annual, @@ -8173,9 +7945,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.PercentCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8183,19 +7955,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" => 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.PercentCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -8203,12 +7975,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", + 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)) ), @@ -8221,12 +7993,7 @@ JsonSerializerOptions options /// /// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.PercentConfig, - global::Orb.Models.Beta.PercentConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PercentConfig : JsonModel { /// @@ -8250,7 +8017,7 @@ public override void Validate() public PercentConfig() { } - public PercentConfig(global::Orb.Models.Beta.PercentConfig percentConfig) + public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } public PercentConfig(IReadOnlyDictionary rawData) @@ -8266,10 +8033,8 @@ public PercentConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -8282,15 +8047,14 @@ public PercentConfig(double percent) } } -class PercentConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.PercentConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.PercentConversionRateConfigConverter))] +[JsonConverter(typeof(PercentConversionRateConfigConverter))] public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8449,11 +8213,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8478,7 +8242,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.PercentConversionRateConfig? other) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -8492,10 +8256,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.PercentConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8560,14 +8323,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.PercentConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.PercentConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8575,25 +8338,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutput, - global::Orb.Models.Beta.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); } } @@ -8601,14 +8357,12 @@ public sealed record class EventOutput : JsonModel /// /// Configuration for event_output pricing /// - public required global::Orb.Models.Beta.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); } } @@ -8711,12 +8465,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.EventOutputConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8878,7 +8632,7 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public EventOutput(global::Orb.Models.Beta.EventOutput eventOutput) + public EventOutput(EventOutput eventOutput) : base(eventOutput) { } public EventOutput(IReadOnlyDictionary rawData) @@ -8896,27 +8650,24 @@ public EventOutput(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.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.Beta.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutput.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputCadenceConverter))] +[JsonConverter(typeof(EventOutputCadenceConverter))] public enum EventOutputCadence { Annual, @@ -8927,9 +8678,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.EventOutputCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8937,19 +8688,19 @@ 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), + "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.EventOutputCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -8957,12 +8708,12 @@ JsonSerializerOptions options 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", + 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)) ), @@ -8975,12 +8726,7 @@ JsonSerializerOptions options /// /// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutputConfig, - global::Orb.Models.Beta.EventOutputConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutputConfig : JsonModel { /// @@ -9035,7 +8781,7 @@ public override void Validate() public EventOutputConfig() { } - public EventOutputConfig(global::Orb.Models.Beta.EventOutputConfig eventOutputConfig) + public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } public EventOutputConfig(IReadOnlyDictionary rawData) @@ -9051,8 +8797,8 @@ public EventOutputConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9067,15 +8813,14 @@ public EventOutputConfig(string unitRatingKey) } } -class EventOutputConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutputConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputConversionRateConfigConverter))] +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9234,11 +8979,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9263,7 +9008,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.EventOutputConversionRateConfig? other) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9278,9 +9023,9 @@ public override string ToString() => } sealed class EventOutputConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.EventOutputConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9345,14 +9090,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.EventOutputConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.EventOutputConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index 3e4b88ad3..69dce5c83 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -41,18 +41,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 +62,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 +81,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 +102,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 +123,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 +144,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) ); @@ -258,25 +256,18 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt } } -[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 +294,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 +310,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 +616,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 +651,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 +665,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 +792,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 +807,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 +839,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 +859,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 +875,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; @@ -1493,10 +1461,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 +1527,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 +1563,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 +1605,13 @@ public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = nul this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public Price(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(Minimum value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1667,16 +1623,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 +1705,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 +1952,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 +2088,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 +2249,45 @@ 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; + value = this.Value as CumulativeGroupedAllocation; 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.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.Minimum` + /// // `value` is of type `Minimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.Minimum? value - ) + public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.Minimum; + value = this.Value as Minimum; return value != null; } @@ -2371,47 +2316,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 +2373,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 +2384,24 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.Percent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2469,7 +2410,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 +2421,24 @@ 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 minimum, System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -2511,7 +2452,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 +2485,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 +2503,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 +2524,19 @@ 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: + case 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 +2562,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 +2573,24 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.Percent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2658,7 +2599,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 +2610,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 +2629,11 @@ 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 minimum, System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -2709,7 +2641,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 +2652,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 +2660,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 +2670,82 @@ 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), + Minimum value => minimum(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 Price(NewPlanUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanBulkPrice value - ) => new(value); + public static implicit operator Price(NewPlanBulkPrice 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(BulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixPrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixWithAllocationPrice 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(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewPlanBulkWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedWithMeteredMinimumPrice 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(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixWithDisplayNamePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanMaxGroupTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator Price(NewPlanScalableMatrixWithUnitPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanCumulativeGroupedBulkPrice 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.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(CumulativeGroupedAllocation 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(Minimum 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 @@ -2933,7 +2801,7 @@ public override void 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 +2815,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 +2906,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3283,11 +3150,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3418,11 +3284,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3578,11 +3443,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3601,11 +3465,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3646,11 +3506,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3669,11 +3525,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3690,40 +3542,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 +3572,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 +3680,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 +3845,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 +3863,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 +3905,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 +3936,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 +3952,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 +3961,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 +4010,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 +4026,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 +4081,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 +4097,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 +4111,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 +4132,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 +4142,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 +4173,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 +4326,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 +4353,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 +4367,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 +4434,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 +4449,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 +4509,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 +4580,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 +4747,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 +4765,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 +4774,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 +4795,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 +4805,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 +4825,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 +4844,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 +4852,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 +4881,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 +4897,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 +4906,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 +4965,7 @@ public override void Validate() public TieredWithProrationConfigTier() { } public TieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } @@ -5222,8 +4982,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 +4991,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 +5158,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 +5187,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 +5202,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 +5269,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 +5285,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 +5307,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 +5417,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 +5584,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 +5602,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 +5611,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 +5634,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 +5644,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 +5664,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 +5684,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 +5754,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -6082,8 +5771,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6091,21 +5780,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 +5947,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 +5976,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 +5991,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 +6058,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 +6074,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 +6096,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 +6206,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 +6373,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 +6391,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 +6400,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 +6423,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 +6433,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 +6453,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 +6473,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 +6543,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -6942,8 +6560,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6951,21 +6569,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 +6736,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 +6765,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 +6780,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 +6847,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 +6862,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Minimum, - global::Orb.Models.Beta.ExternalPlanID.MinimumFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Minimum : 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); } } @@ -7293,14 +6894,12 @@ public required string ItemID /// /// Configuration for minimum pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.MinimumConfig MinimumConfig + public required MinimumConfig MinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("minimum_config"); } init { this._rawData.Set("minimum_config", value); } } @@ -7390,12 +6989,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 MinimumConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7552,7 +7151,7 @@ public Minimum() this.ModelType = JsonSerializer.SerializeToElement("minimum"); } - public Minimum(global::Orb.Models.Beta.ExternalPlanID.Minimum minimum) + public Minimum(Minimum minimum) : base(minimum) { } public Minimum(IReadOnlyDictionary rawData) @@ -7570,27 +7169,24 @@ public Minimum(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Minimum FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class MinimumFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Minimum.FromRawUnchecked(rawData); + public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => + Minimum.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumCadenceConverter))] +[JsonConverter(typeof(MinimumCadenceConverter))] public enum MinimumCadence { Annual, @@ -7601,10 +7197,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter - : JsonConverter +sealed class MinimumCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumCadence Read( + public override MinimumCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7612,19 +7207,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" => MinimumCadence.Annual, + "semi_annual" => MinimumCadence.SemiAnnual, + "monthly" => MinimumCadence.Monthly, + "quarterly" => MinimumCadence.Quarterly, + "one_time" => MinimumCadence.OneTime, + "custom" => MinimumCadence.Custom, + _ => (MinimumCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence value, + MinimumCadence value, JsonSerializerOptions options ) { @@ -7632,12 +7227,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", + MinimumCadence.Annual => "annual", + MinimumCadence.SemiAnnual => "semi_annual", + MinimumCadence.Monthly => "monthly", + MinimumCadence.Quarterly => "quarterly", + MinimumCadence.OneTime => "one_time", + MinimumCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7650,12 +7245,7 @@ JsonSerializerOptions options /// /// Configuration for minimum pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.MinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.MinimumConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class MinimumConfig : JsonModel { /// @@ -7701,7 +7291,7 @@ public override void Validate() public MinimumConfig() { } - public MinimumConfig(global::Orb.Models.Beta.ExternalPlanID.MinimumConfig minimumConfig) + public MinimumConfig(MinimumConfig minimumConfig) : base(minimumConfig) { } public MinimumConfig(IReadOnlyDictionary rawData) @@ -7717,10 +7307,8 @@ public MinimumConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -7733,15 +7321,14 @@ public MinimumConfig(string minimumAmount) } } -class MinimumConfigFromRaw : IFromRawJson +class MinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.MinimumConfig.FromRawUnchecked(rawData); + public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + MinimumConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfigConverter))] +[JsonConverter(typeof(MinimumConversionRateConfigConverter))] public record class MinimumConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7900,11 +7487,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator MinimumConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator MinimumConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7929,9 +7516,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? other - ) + public virtual bool Equals(MinimumConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7945,10 +7530,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class MinimumConversionRateConfigConverter - : JsonConverter +sealed class MinimumConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? Read( + public override MinimumConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8013,16 +7597,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( - element - ); + return new MinimumConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig value, + MinimumConversionRateConfig value, JsonSerializerOptions options ) { @@ -8030,25 +7612,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Percent, - global::Orb.Models.Beta.ExternalPlanID.PercentFromRaw - >) -)] +[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); } } @@ -8095,14 +7670,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.PercentConfig PercentConfig + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullClass("percent_config"); } init { this._rawData.Set("percent_config", value); } } @@ -8166,12 +7739,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 PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8328,7 +7901,7 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Percent(global::Orb.Models.Beta.ExternalPlanID.Percent percent) + public Percent(Percent percent) : base(percent) { } public Percent(IReadOnlyDictionary rawData) @@ -8346,27 +7919,24 @@ public Percent(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Percent.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.PercentCadenceConverter))] +[JsonConverter(typeof(PercentCadenceConverter))] public enum PercentCadence { Annual, @@ -8377,10 +7947,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8388,19 +7957,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" => 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.PercentCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -8408,12 +7977,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", + 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)) ), @@ -8425,13 +7994,8 @@ JsonSerializerOptions options /// /// Configuration for percent pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.PercentConfig, - global::Orb.Models.Beta.ExternalPlanID.PercentConfigFromRaw - >) -)] +/// +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PercentConfig : JsonModel { /// @@ -8455,7 +8019,7 @@ public override void Validate() public PercentConfig() { } - public PercentConfig(global::Orb.Models.Beta.ExternalPlanID.PercentConfig percentConfig) + public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } public PercentConfig(IReadOnlyDictionary rawData) @@ -8471,10 +8035,8 @@ public PercentConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -8487,15 +8049,14 @@ public PercentConfig(double percent) } } -class PercentConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.PercentConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfigConverter))] +[JsonConverter(typeof(PercentConversionRateConfigConverter))] public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8654,11 +8215,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8683,9 +8244,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? other - ) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -8699,10 +8258,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8767,16 +8325,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( - element - ); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8784,28 +8340,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.EventOutput, - global::Orb.Models.Beta.ExternalPlanID.EventOutputFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence - > 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); } } @@ -8813,14 +8359,12 @@ public required ApiEnum< /// /// Configuration for event_output pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.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); } } @@ -8923,12 +8467,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9090,7 +8634,7 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public EventOutput(global::Orb.Models.Beta.ExternalPlanID.EventOutput eventOutput) + public EventOutput(EventOutput eventOutput) : base(eventOutput) { } public EventOutput(IReadOnlyDictionary rawData) @@ -9108,27 +8652,24 @@ public EventOutput(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.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.Beta.ExternalPlanID.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutput.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.EventOutputCadenceConverter))] +[JsonConverter(typeof(EventOutputCadenceConverter))] public enum EventOutputCadence { Annual, @@ -9139,10 +8680,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9150,19 +8690,19 @@ 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), + "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.EventOutputCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -9170,13 +8710,12 @@ JsonSerializerOptions options 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", + 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)) ), @@ -9189,12 +8728,7 @@ JsonSerializerOptions options /// /// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutputConfig : JsonModel { /// @@ -9249,9 +8783,7 @@ public override void Validate() public EventOutputConfig() { } - public EventOutputConfig( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig eventOutputConfig - ) + public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } public EventOutputConfig(IReadOnlyDictionary rawData) @@ -9267,8 +8799,8 @@ public EventOutputConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9283,18 +8815,14 @@ public EventOutputConfig(string unitRatingKey) } } -class EventOutputConfigFromRaw - : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfigConverter) -)] +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9453,11 +8981,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9482,9 +9010,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? other - ) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9499,9 +9025,9 @@ public override string ToString() => } sealed class EventOutputConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9566,16 +9092,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( - element - ); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -9583,12 +9107,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment, - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustmentFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class RemoveAdjustment : JsonModel { /// @@ -9626,9 +9145,7 @@ public override void Validate() public RemoveAdjustment() { } - public RemoveAdjustment( - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment removeAdjustment - ) + public RemoveAdjustment(RemoveAdjustment removeAdjustment) : base(removeAdjustment) { } public RemoveAdjustment(IReadOnlyDictionary rawData) @@ -9644,8 +9161,8 @@ public RemoveAdjustment(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( + /// + public static RemoveAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9660,21 +9177,14 @@ public RemoveAdjustment(string adjustmentID) } } -class RemoveAdjustmentFromRaw - : IFromRawJson +class RemoveAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment.FromRawUnchecked(rawData); + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.RemovePrice, - global::Orb.Models.Beta.ExternalPlanID.RemovePriceFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class RemovePrice : JsonModel { /// @@ -9712,7 +9222,7 @@ public override void Validate() public RemovePrice() { } - public RemovePrice(global::Orb.Models.Beta.ExternalPlanID.RemovePrice removePrice) + public RemovePrice(RemovePrice removePrice) : base(removePrice) { } public RemovePrice(IReadOnlyDictionary rawData) @@ -9728,10 +9238,8 @@ public RemovePrice(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -9744,33 +9252,25 @@ public RemovePrice(string priceID) } } -class RemovePriceFromRaw : IFromRawJson +class RemovePriceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemovePrice.FromRawUnchecked(rawData); + public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + RemovePrice.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] 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 + public required ReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" - ); + return this._rawData.GetNotNullClass("adjustment"); } init { this._rawData.Set("adjustment", value); } } @@ -9811,9 +9311,7 @@ public override void Validate() public ReplaceAdjustment() { } - public ReplaceAdjustment( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment replaceAdjustment - ) + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) : base(replaceAdjustment) { } public ReplaceAdjustment(IReadOnlyDictionary rawData) @@ -9829,8 +9327,8 @@ public ReplaceAdjustment(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( + /// + public static ReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9838,19 +9336,17 @@ IReadOnlyDictionary rawData } } -class ReplaceAdjustmentFromRaw - : IFromRawJson +class ReplaceAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment.FromRawUnchecked(rawData); + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); } /// /// The definition of a new adjustment to create and add to the plan. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustmentConverter))] +[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] public record class ReplaceAdjustmentAdjustment : ModelBase { public object? Value { get; } = null; @@ -10136,25 +9632,18 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewPercentageDiscount value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewUsageDiscount value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewAmountDiscount value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewMinimum value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewMaximum 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 @@ -10183,9 +9672,7 @@ public override void Validate() ); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? other - ) + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -10199,10 +9686,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplaceAdjustmentAdjustmentConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? Read( + public override ReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -10327,16 +9813,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - element - ); + return new ReplaceAdjustmentAdjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment value, + ReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { @@ -10344,12 +9828,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePrice, - global::Orb.Models.Beta.ExternalPlanID.ReplacePriceFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class ReplacePrice : JsonModel { /// @@ -10394,14 +9873,12 @@ public long? PlanPhaseOrder /// /// New plan price request body params. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? Price + public ReplacePricePrice? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "price" - ); + return this._rawData.GetNullableClass("price"); } init { this._rawData.Set("price", value); } } @@ -10417,7 +9894,7 @@ public override void Validate() public ReplacePrice() { } - public ReplacePrice(global::Orb.Models.Beta.ExternalPlanID.ReplacePrice replacePrice) + public ReplacePrice(ReplacePrice replacePrice) : base(replacePrice) { } public ReplacePrice(IReadOnlyDictionary rawData) @@ -10433,10 +9910,8 @@ public ReplacePrice(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -10449,18 +9924,17 @@ public ReplacePrice(string replacesPriceID) } } -class ReplacePriceFromRaw : IFromRawJson +class ReplacePriceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePrice.FromRawUnchecked(rawData); + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); } /// /// New plan price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceConverter))] +[JsonConverter(typeof(ReplacePricePriceConverter))] public record class ReplacePricePrice : ModelBase { public object? Value { get; } = null; @@ -11029,10 +10503,7 @@ public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) this._element = element; } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value, - JsonElement? element = null - ) + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -11102,7 +10573,7 @@ public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? el } public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value, + ReplacePricePriceTieredWithProration value, JsonElement? element = null ) { @@ -11147,7 +10618,7 @@ public ReplacePricePrice( } public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value, + ReplacePricePriceGroupedWithMinMaxThresholds value, JsonElement? element = null ) { @@ -11198,7 +10669,7 @@ public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? e } public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value, + ReplacePricePriceCumulativeGroupedAllocation value, JsonElement? element = null ) { @@ -11206,10 +10677,7 @@ public ReplacePricePrice( this._element = element; } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value, - JsonElement? element = null - ) + public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -11221,19 +10689,13 @@ public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? elemen this._element = element; } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value, - JsonElement? element = null - ) + public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value, - JsonElement? element = null - ) + public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -11309,26 +10771,24 @@ 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.ReplacePricePriceBulkWithFilters` + /// // `value` is of type `ReplacePricePriceBulkWithFilters` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters? value + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value ) { - value = - this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters; + value = this.Value as ReplacePricePriceBulkWithFilters; return value != null; } @@ -11560,27 +11020,24 @@ 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.ReplacePricePriceTieredWithProration` + /// // `value` is of type `ReplacePricePriceTieredWithProration` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickTieredWithProration( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration? value + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value ) { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration; + value = this.Value as ReplacePricePriceTieredWithProration; return value != null; } @@ -11701,27 +11158,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.ReplacePricePriceGroupedWithMinMaxThresholds` + /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds? value + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value ) { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds; + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; return value != null; } @@ -11865,51 +11319,45 @@ 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.ReplacePricePriceCumulativeGroupedAllocation` + /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation? value + [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value ) { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation; + 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.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum` + /// // `value` is of type `ReplacePricePriceMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum? value - ) + public bool TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum; + value = this.Value as ReplacePricePriceMinimum; return value != null; } @@ -11938,49 +11386,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.ReplacePricePricePercent` + /// // `value` is of type `ReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent? value - ) + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent; + 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.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput` + /// // `value` is of type `ReplacePricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput; + value = this.Value as ReplacePricePriceEventOutput; return value != null; } @@ -12001,7 +11443,7 @@ public bool TryPickEventOutput( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -12012,24 +11454,24 @@ public bool TryPickEventOutput( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (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) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (ReplacePricePriceMinimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value) => {...} + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} /// ); /// /// @@ -12038,7 +11480,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, @@ -12049,24 +11491,24 @@ 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 minimum, System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -12080,7 +11522,7 @@ public void Switch( case NewPlanBulkPrice value: newPlanBulk(value); break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value: + case ReplacePricePriceBulkWithFilters value: bulkWithFilters(value); break; case NewPlanPackagePrice value: @@ -12113,7 +11555,7 @@ public void Switch( case NewPlanMatrixWithAllocationPrice value: newPlanMatrixWithAllocation(value); break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value: + case ReplacePricePriceTieredWithProration value: tieredWithProration(value); break; case NewPlanUnitWithProrationPrice value: @@ -12131,7 +11573,7 @@ public void Switch( case NewPlanGroupedWithMeteredMinimumPrice value: newPlanGroupedWithMeteredMinimum(value); break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value: + case ReplacePricePriceGroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; case NewPlanMatrixWithDisplayNamePrice value: @@ -12152,19 +11594,19 @@ public void Switch( case NewPlanCumulativeGroupedBulkPrice value: newPlanCumulativeGroupedBulk(value); break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value: + case ReplacePricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value: + case ReplacePricePriceMinimum value: minimum(value); break; case NewPlanMinimumCompositePrice value: newPlanMinimumComposite(value); break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value: + case ReplacePricePricePercent value: percent(value); break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value: + case ReplacePricePriceEventOutput value: eventOutput(value); break; default: @@ -12192,7 +11634,7 @@ public void Switch( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -12203,24 +11645,24 @@ public void Switch( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (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) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (ReplacePricePriceMinimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value) => {...} + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} /// ); /// /// @@ -12229,10 +11671,7 @@ public T Match( System::Func newPlanUnit, System::Func newPlanTiered, System::Func newPlanBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - T - > bulkWithFilters, + System::Func bulkWithFilters, System::Func newPlanPackage, System::Func newPlanMatrix, System::Func newPlanThresholdTotalAmount, @@ -12243,19 +11682,13 @@ public T Match( System::Func newPlanPackageWithAllocation, System::Func newPlanUnitWithPercent, System::Func newPlanMatrixWithAllocation, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration, - 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.ReplacePricePriceGroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, + System::Func groupedWithMinMaxThresholds, System::Func newPlanMatrixWithDisplayName, System::Func newPlanGroupedTieredPackage, System::Func newPlanMaxGroupTieredPackage, @@ -12268,17 +11701,11 @@ public T Match( T > newPlanScalableMatrixWithTieredPricing, System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, + System::Func minimum, System::Func newPlanMinimumComposite, - System::Func percent, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput, - T - > eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -12286,8 +11713,7 @@ public T Match( NewPlanUnitPrice value => newPlanUnit(value), NewPlanTieredPrice value => newPlanTiered(value), NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value => - bulkWithFilters(value), + ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), NewPlanPackagePrice value => newPlanPackage(value), NewPlanMatrixPrice value => newPlanMatrix(value), NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), @@ -12298,8 +11724,7 @@ public T Match( NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value => - tieredWithProration(value), + ReplacePricePriceTieredWithProration value => tieredWithProration(value), NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), @@ -12307,8 +11732,9 @@ public T Match( value ), NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), + ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( + value + ), NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), @@ -12318,146 +11744,113 @@ public T Match( 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), + ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( + value + ), + 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), + ReplacePricePricePercent value => percent(value), + 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 ReplacePricePrice(NewPlanUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkPrice value - ) => new(value); + public static implicit operator 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 ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackagePrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackagePrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredWithMinimumPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithPercentPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator 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 ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithProrationPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedAllocationPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkWithProrationPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( + public static implicit operator ReplacePricePrice( NewPlanGroupedWithProratedMinimumPrice value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( + public static implicit operator ReplacePricePrice( NewPlanGroupedWithMeteredMinimumPrice value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( + public static implicit operator ReplacePricePrice( NewPlanScalableMatrixWithUnitPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( + public static implicit operator ReplacePricePrice( NewPlanScalableMatrixWithTieredPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value + public static implicit operator ReplacePricePrice( + 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 ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMinimumCompositePrice value - ) => new(value); + public static implicit operator 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 ReplacePricePrice(ReplacePricePricePercent value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput 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 @@ -12515,7 +11908,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? other) + public virtual bool Equals(ReplacePricePrice? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -12529,10 +11922,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceConverter - : JsonConverter +sealed class ReplacePricePriceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? Read( + public override ReplacePricePrice? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -12621,11 +12013,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -12867,7 +12258,7 @@ JsonSerializerOptions options try { var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, options ); @@ -13002,7 +12393,7 @@ JsonSerializerOptions options try { var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, options ); @@ -13162,7 +12553,7 @@ JsonSerializerOptions options try { var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, options ); @@ -13184,11 +12575,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -13229,11 +12619,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -13252,11 +12641,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -13273,14 +12661,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice(element); + return new ReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? value, + ReplacePricePrice? value, JsonSerializerOptions options ) { @@ -13290,8 +12678,8 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersFromRaw + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw >) )] public sealed record class ReplacePricePriceBulkWithFilters : JsonModel @@ -13299,12 +12687,12 @@ public sealed record class ReplacePricePriceBulkWithFilters : JsonModel /// /// Configuration for bulk_with_filters pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "bulk_with_filters_config" ); } @@ -13314,19 +12702,13 @@ public sealed record class ReplacePricePriceBulkWithFilters : JsonModel /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -13430,12 +12812,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -13598,7 +12980,7 @@ public ReplacePricePriceBulkWithFilters() } public ReplacePricePriceBulkWithFilters( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) : base(replacePricePriceBulkWithFilters) { } @@ -13617,8 +12999,8 @@ public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13626,16 +13008,12 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters FromRawUnchecked( + public ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); } /// @@ -13643,8 +13021,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw >) )] public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel @@ -13652,19 +13030,19 @@ public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig /// /// Property filters to apply (all must match) /// - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("filters"); } init { this._rawData.Set< - ImmutableArray + ImmutableArray >("filters", ImmutableArray.ToImmutableArray(value)); } } @@ -13672,19 +13050,19 @@ public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig /// /// 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)); } } @@ -13705,7 +13083,7 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } @@ -13726,8 +13104,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13736,15 +13114,12 @@ IReadOnlyDictionary rawData } class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); } /// @@ -13752,8 +13127,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw >) )] public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel @@ -13794,7 +13169,7 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } @@ -13815,8 +13190,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13825,15 +13200,12 @@ IReadOnlyDictionary rawData } class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); } /// @@ -13841,8 +13213,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw >) )] public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel @@ -13883,7 +13255,7 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } @@ -13904,8 +13276,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13921,23 +13293,18 @@ public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmou } class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadenceConverter) -)] +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] public enum ReplacePricePriceBulkWithFiltersCadence { Annual, @@ -13949,9 +13316,9 @@ public enum ReplacePricePriceBulkWithFiltersCadence } sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence Read( + public override ReplacePricePriceBulkWithFiltersCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -13959,51 +13326,19 @@ 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 - ), + "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, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence value, + ReplacePricePriceBulkWithFiltersCadence value, JsonSerializerOptions options ) { @@ -14011,42 +13346,12 @@ JsonSerializerOptions options writer, value switch { - 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", + 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)) ), @@ -14056,9 +13361,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -14217,11 +13520,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -14246,9 +13549,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -14263,9 +13564,9 @@ public override string ToString() => } sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14330,16 +13631,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( - element - ); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -14349,8 +13648,8 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] public sealed record class ReplacePricePriceTieredWithProration : JsonModel @@ -14358,19 +13657,13 @@ public sealed record class ReplacePricePriceTieredWithProration : JsonModel /// /// 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); } @@ -14418,12 +13711,12 @@ public required string Name /// /// Configuration for tiered_with_proration pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_with_proration_config" ); } @@ -14489,12 +13782,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 ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14657,7 +13950,7 @@ public ReplacePricePriceTieredWithProration() } public ReplacePricePriceTieredWithProration( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) : base(replacePricePriceTieredWithProration) { } @@ -14676,8 +13969,8 @@ public ReplacePricePriceTieredWithProration(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14686,23 +13979,18 @@ IReadOnlyDictionary rawData } class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadenceConverter) -)] +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] public enum ReplacePricePriceTieredWithProrationCadence { Annual, @@ -14714,9 +14002,9 @@ public enum ReplacePricePriceTieredWithProrationCadence } sealed class ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence Read( + public override ReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14724,52 +14012,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "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 - ), + "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.ReplacePricePriceTieredWithProrationCadence value, + ReplacePricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -14777,42 +14032,12 @@ JsonSerializerOptions options 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", + 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)) ), @@ -14827,8 +14052,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel @@ -14837,19 +14062,19 @@ public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrati /// 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 + ImmutableArray >("tiers"); } init { this._rawData.Set< - ImmutableArray + ImmutableArray >("tiers", ImmutableArray.ToImmutableArray(value)); } } @@ -14866,7 +14091,7 @@ public override void Validate() public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig ) : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } @@ -14887,8 +14112,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14897,7 +14122,7 @@ IReadOnlyDictionary rawData [SetsRequiredMembers] public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers + IReadOnlyList tiers ) : this() { @@ -14906,15 +14131,12 @@ public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( } class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); } /// @@ -14922,8 +14144,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw >) )] public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier @@ -14965,7 +14187,7 @@ public override void Validate() public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } @@ -14986,8 +14208,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14996,20 +14218,16 @@ IReadOnlyDictionary rawData } class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( - rawData - ); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfigConverter) -)] +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15168,11 +14386,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15197,9 +14415,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -15214,9 +14430,9 @@ public override string ToString() => } sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15281,16 +14497,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -15300,8 +14514,8 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel @@ -15309,19 +14523,13 @@ public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonMo /// /// 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); } @@ -15330,12 +14538,12 @@ public required ApiEnum< /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -15440,12 +14648,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15608,7 +14816,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholds() } public ReplacePricePriceGroupedWithMinMaxThresholds( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) : base(replacePricePriceGroupedWithMinMaxThresholds) { } @@ -15629,8 +14837,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15639,23 +14847,18 @@ IReadOnlyDictionary rawData } class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) -)] +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, @@ -15667,9 +14870,9 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence } sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15677,52 +14880,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" => 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.ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -15730,42 +14900,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", + 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)) ), @@ -15780,8 +14920,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig @@ -15851,7 +14991,7 @@ public override void Validate() public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } @@ -15872,8 +15012,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15882,20 +15022,18 @@ IReadOnlyDictionary rawData } class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16054,11 +15192,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16084,7 +15222,7 @@ public override void Validate() } public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -16100,9 +15238,9 @@ public override string ToString() => } sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16167,7 +15305,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -16176,7 +15314,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -16186,8 +15324,8 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel @@ -16195,19 +15333,13 @@ public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonMo /// /// 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); } @@ -16216,12 +15348,12 @@ public required ApiEnum< /// /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -16326,12 +15458,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16494,7 +15626,7 @@ public ReplacePricePriceCumulativeGroupedAllocation() } public ReplacePricePriceCumulativeGroupedAllocation( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) : base(replacePricePriceCumulativeGroupedAllocation) { } @@ -16515,8 +15647,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16525,23 +15657,18 @@ IReadOnlyDictionary rawData } class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadenceConverter) -)] +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, @@ -16553,9 +15680,9 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence } sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16563,52 +15690,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" => 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.ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -16616,42 +15710,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", + 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)) ), @@ -16666,8 +15730,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig @@ -16737,7 +15801,7 @@ public override void Validate() public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } @@ -16758,8 +15822,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16768,20 +15832,18 @@ IReadOnlyDictionary rawData } class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) -)] +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16940,11 +16002,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16970,7 +16032,7 @@ public override void Validate() } public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -16986,9 +16048,9 @@ public override string ToString() => } sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17053,7 +16115,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -17062,7 +16124,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17071,30 +16133,21 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class ReplacePricePriceMinimum : 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 - > - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -17115,12 +16168,12 @@ public required string ItemID /// /// Configuration for minimum pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required ReplacePricePriceMinimumMinimumConfig MinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "minimum_config" ); } @@ -17212,12 +16265,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 ReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -17374,9 +16427,7 @@ public ReplacePricePriceMinimum() this.ModelType = JsonSerializer.SerializeToElement("minimum"); } - public ReplacePricePriceMinimum( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum replacePricePriceMinimum - ) + public ReplacePricePriceMinimum(ReplacePricePriceMinimum replacePricePriceMinimum) : base(replacePricePriceMinimum) { } public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) @@ -17394,8 +16445,8 @@ public ReplacePricePriceMinimum(IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceMinimum FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17403,21 +16454,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw - : IFromRawJson +class ReplacePricePriceMinimumFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceMinimum FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceMinimum.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadenceConverter) -)] +[JsonConverter(typeof(ReplacePricePriceMinimumCadenceConverter))] public enum ReplacePricePriceMinimumCadence { Annual, @@ -17429,9 +16477,9 @@ public enum ReplacePricePriceMinimumCadence } sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceMinimumCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17439,49 +16487,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" => ReplacePricePriceMinimumCadence.Annual, + "semi_annual" => ReplacePricePriceMinimumCadence.SemiAnnual, + "monthly" => ReplacePricePriceMinimumCadence.Monthly, + "quarterly" => ReplacePricePriceMinimumCadence.Quarterly, + "one_time" => ReplacePricePriceMinimumCadence.OneTime, + "custom" => ReplacePricePriceMinimumCadence.Custom, + _ => (ReplacePricePriceMinimumCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence value, + ReplacePricePriceMinimumCadence value, JsonSerializerOptions options ) { @@ -17489,18 +16507,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", + ReplacePricePriceMinimumCadence.Annual => "annual", + ReplacePricePriceMinimumCadence.SemiAnnual => "semi_annual", + ReplacePricePriceMinimumCadence.Monthly => "monthly", + ReplacePricePriceMinimumCadence.Quarterly => "quarterly", + ReplacePricePriceMinimumCadence.OneTime => "one_time", + ReplacePricePriceMinimumCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17515,8 +16527,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfigFromRaw + ReplacePricePriceMinimumMinimumConfig, + ReplacePricePriceMinimumMinimumConfigFromRaw >) )] public sealed record class ReplacePricePriceMinimumMinimumConfig : JsonModel @@ -17565,7 +16577,7 @@ public override void Validate() public ReplacePricePriceMinimumMinimumConfig() { } public ReplacePricePriceMinimumMinimumConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig + ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig ) : base(replacePricePriceMinimumMinimumConfig) { } @@ -17582,8 +16594,8 @@ public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17599,20 +16611,15 @@ public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) } class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfigConverter) -)] +[JsonConverter(typeof(ReplacePricePriceMinimumConversionRateConfigConverter))] public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17771,11 +16778,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceMinimumConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceMinimumConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17800,9 +16807,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceMinimumConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -17817,9 +16822,9 @@ public override string ToString() => } sealed class ReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceMinimumConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17884,16 +16889,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( - element - ); + return new ReplacePricePriceMinimumConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceMinimumConversionRateConfig value, JsonSerializerOptions options ) { @@ -17902,30 +16905,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 +16966,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 +17037,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 +17199,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 +17217,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 +17226,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 +17249,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 +17259,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 +17279,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 +17299,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 +17327,7 @@ public override void Validate() public ReplacePricePricePercentPercentConfig() { } public ReplacePricePricePercentPercentConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig + ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig ) : base(replacePricePricePercentPercentConfig) { } @@ -18391,8 +17344,8 @@ public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig FromRawUnchecked( + /// + public static ReplacePricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18408,20 +17361,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 +17528,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 +17557,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 +17572,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 +17639,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 +17655,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 +17677,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 +17787,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 +17954,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 +17972,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 +17981,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 +18004,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 +18014,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 +18034,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 +18054,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 +18113,7 @@ public override void Validate() public ReplacePricePriceEventOutputEventOutputConfig() { } public ReplacePricePriceEventOutputEventOutputConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig + ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig ) : base(replacePricePriceEventOutputEventOutputConfig) { } @@ -19257,8 +18132,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( + /// + public static ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19274,20 +18149,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 +18316,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 +18345,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 +18360,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 +18427,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/PlanVersionPhase.cs b/src/Orb/Models/Beta/PlanVersionPhase.cs index c31e3cce9..b988baf92 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/CouponCreateParams.cs b/src/Orb/Models/Coupons/CouponCreateParams.cs index 036e75ba0..c21d29d7a 100644 --- a/src/Orb/Models/Coupons/CouponCreateParams.cs +++ b/src/Orb/Models/Coupons/CouponCreateParams.cs @@ -23,14 +23,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); } } @@ -298,10 +296,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 +319,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 +333,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 +394,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/CreditBlocks/CreditBlockRetrieveResponse.cs b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs index 473a89a0a..a8c8534a5 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 d77b47d4a..043977ed7 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs @@ -47,18 +47,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 +66,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); } } @@ -201,12 +197,7 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.CreditNotes.LineItem, - global::Orb.Models.CreditNotes.LineItemFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class LineItem : JsonModel { /// @@ -279,7 +270,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 +286,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 +312,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 +322,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/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs index ac1d4a588..ea000d1ad 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs @@ -141,7 +141,7 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt } } -[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 226a4f498..3ebf70c79 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/Credits/CreditListResponse.cs b/src/Orb/Models/Customers/Credits/CreditListResponse.cs index 240ac4334..d7ce8b6bf 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/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index 47c8a79f9..a667df269 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -800,18 +800,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 +934,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 +953,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 +992,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 +1008,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 +1041,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 +1065,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 +1082,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/CustomerCreateParams.cs b/src/Orb/Models/Customers/CustomerCreateParams.cs index f548db5bd..f59773040 100644 --- a/src/Orb/Models/Customers/CustomerCreateParams.cs +++ b/src/Orb/Models/Customers/CustomerCreateParams.cs @@ -499,14 +499,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 +515,7 @@ public sealed record class PaymentConfiguration : JsonModel return; } - this._rawData.Set?>( + this._rawData.Set?>( "payment_providers", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -566,9 +566,7 @@ IReadOnlyDictionary rawData ) => PaymentConfiguration.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PaymentProvider : JsonModel { /// @@ -623,7 +621,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 +638,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 +651,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/Events/Backfills/BackfillCreateResponse.cs b/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs index 8e39a8db8..686a4118b 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/Volume/EventVolumes.cs b/src/Orb/Models/Events/Volume/EventVolumes.cs index 617b5f4dc..bd74c288e 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/InvoiceLineItems/InvoiceLineItemCreateResponse.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs index 8e2e54507..d34fc7c74 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 c572f34f6..c7f207722 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -51,18 +51,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) ); @@ -276,12 +274,7 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.LineItem, - global::Orb.Models.Invoices.LineItemFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class LineItem : JsonModel { /// @@ -307,14 +300,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 +376,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 +392,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 +422,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 +437,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/InvoiceFetchUpcomingResponse.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs index 01a532f8c..a398e2e80 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/InvoiceListParams.cs b/src/Orb/Models/Invoices/InvoiceListParams.cs index 3abf3b01e..440cce8cc 100644 --- a/src/Orb/Models/Invoices/InvoiceListParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListParams.cs @@ -222,20 +222,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) + ); } } @@ -345,7 +346,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 +356,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 +366,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/Metrics/BillableMetric.cs b/src/Orb/Models/Metrics/BillableMetric.cs index b0711a9a9..ecd533368 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/Plans/Migrations/MigrationRetrieveResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs index 79e6faa81..10e33b6ce 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/PlanCreateParams.cs b/src/Orb/Models/Plans/PlanCreateParams.cs index 16b4882a9..f4711b6aa 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -50,18 +50,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 +70,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 +171,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 { @@ -269,7 +263,7 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Price : JsonModel { /// @@ -321,7 +315,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 +332,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); } /// @@ -926,7 +917,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 +983,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 +1019,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 +1064,13 @@ public PricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element this._element = element; } - public PricePrice( - global::Orb.Models.Plans.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public PricePrice(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(global::Orb.Models.Plans.Minimum value, JsonElement? element = null) + public PricePrice(Minimum value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1100,13 +1082,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 +1164,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 +1411,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 +1547,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 +1708,45 @@ 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; + value = this.Value as CumulativeGroupedAllocation; 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.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.Minimum` + /// // `value` is of type `Minimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Plans.Minimum? value) + public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) { - value = this.Value as global::Orb.Models.Plans.Minimum; + value = this.Value as Minimum; return value != null; } @@ -1797,45 +1775,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 +1832,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 +1843,24 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Plans.Percent value) => {...}, - /// (global::Orb.Models.Plans.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1893,7 +1869,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 +1880,24 @@ 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 minimum, System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -1935,7 +1911,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 +1944,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 +1962,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 +1983,19 @@ 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: + case 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 +2021,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 +2032,24 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Plans.Percent value) => {...}, - /// (global::Orb.Models.Plans.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2082,7 +2058,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 +2069,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 +2088,11 @@ 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 minimum, System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -2130,7 +2100,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 +2111,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 +2119,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 +2129,11 @@ 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), + Minimum value => minimum(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 +2144,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 +2170,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 +2184,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 +2204,15 @@ 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(CumulativeGroupedAllocation value) => new(value); - public static implicit operator PricePrice(global::Orb.Models.Plans.Minimum value) => - new(value); + public static implicit operator PricePrice(Minimum 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 @@ -2415,11 +2373,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2660,11 +2617,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2795,11 +2751,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2955,11 +2910,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2978,10 +2932,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3022,10 +2973,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3044,11 +2992,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3080,25 +3024,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 +3043,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 +3151,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 +3316,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 +3334,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 +3376,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 +3407,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 +3423,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 +3432,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 +3481,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 +3497,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 +3552,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 +3568,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 +3582,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 +3603,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 +3613,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 +3644,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 +3797,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 +3824,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 +3838,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 +3905,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 +3920,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 +3980,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 +4051,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 +4218,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 +4236,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 +4245,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 +4266,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 +4276,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 +4296,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 +4315,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 +4323,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 +4352,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 +4368,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 +4377,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 +4436,7 @@ public override void Validate() public TieredWithProrationConfigTier() { } public TieredWithProrationConfigTier( - global::Orb.Models.Plans.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } @@ -4571,8 +4453,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 +4462,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 +4629,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 +4658,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 +4673,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 +4740,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 +4756,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 +4778,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 +4888,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 +5055,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 +5073,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 +5082,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 +5105,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 +5115,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 +5135,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 +5155,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 +5225,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -5376,8 +5242,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5385,18 +5251,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 +5418,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 +5447,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 +5462,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 +5529,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 +5545,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 +5567,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 +5677,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 +5844,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 +5862,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 +5871,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 +5894,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 +5904,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 +5924,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 +5944,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 +6014,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Plans.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -6183,8 +6031,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6192,18 +6040,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 +6207,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 +6236,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 +6251,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 +6318,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,12 +6333,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Minimum, - global::Orb.Models.Plans.MinimumFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Minimum : JsonModel { /// @@ -6529,14 +6365,12 @@ public required string ItemID /// /// Configuration for minimum pricing /// - public required global::Orb.Models.Plans.MinimumConfig MinimumConfig + public required MinimumConfig MinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("minimum_config"); } init { this._rawData.Set("minimum_config", value); } } @@ -6788,7 +6622,7 @@ public Minimum() this.ModelType = JsonSerializer.SerializeToElement("minimum"); } - public Minimum(global::Orb.Models.Plans.Minimum minimum) + public Minimum(Minimum minimum) : base(minimum) { } public Minimum(IReadOnlyDictionary rawData) @@ -6806,21 +6640,18 @@ public Minimum(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Minimum FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class MinimumFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Minimum.FromRawUnchecked(rawData); + public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => + Minimum.FromRawUnchecked(rawData); } /// @@ -6885,12 +6716,7 @@ JsonSerializerOptions options /// /// Configuration for minimum pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.MinimumConfig, - global::Orb.Models.Plans.MinimumConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class MinimumConfig : JsonModel { /// @@ -6936,7 +6762,7 @@ public override void Validate() public MinimumConfig() { } - public MinimumConfig(global::Orb.Models.Plans.MinimumConfig minimumConfig) + public MinimumConfig(MinimumConfig minimumConfig) : base(minimumConfig) { } public MinimumConfig(IReadOnlyDictionary rawData) @@ -6952,10 +6778,8 @@ public MinimumConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -6968,12 +6792,11 @@ public MinimumConfig(string minimumAmount) } } -class MinimumConfigFromRaw : IFromRawJson +class MinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.MinimumConfig.FromRawUnchecked(rawData); + public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + MinimumConfig.FromRawUnchecked(rawData); } [JsonConverter(typeof(MinimumConversionRateConfigConverter))] @@ -7260,25 +7083,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Percent, - global::Orb.Models.Plans.PercentFromRaw - >) -)] +[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); } } @@ -7325,14 +7141,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required global::Orb.Models.Plans.PercentConfig PercentConfig + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullClass("percent_config"); } init { this._rawData.Set("percent_config", value); } } @@ -7396,12 +7210,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Plans.PercentConversionRateConfig? ConversionRateConfig + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7558,7 +7372,7 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Percent(global::Orb.Models.Plans.Percent percent) + public Percent(Percent percent) : base(percent) { } public Percent(IReadOnlyDictionary rawData) @@ -7576,27 +7390,24 @@ public Percent(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Percent.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.PercentCadenceConverter))] +[JsonConverter(typeof(PercentCadenceConverter))] public enum PercentCadence { Annual, @@ -7607,9 +7418,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.PercentCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7617,19 +7428,19 @@ 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), + "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.Plans.PercentCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -7637,12 +7448,12 @@ JsonSerializerOptions options 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", + 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)) ), @@ -7655,12 +7466,7 @@ JsonSerializerOptions options /// /// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.PercentConfig, - global::Orb.Models.Plans.PercentConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PercentConfig : JsonModel { /// @@ -7684,7 +7490,7 @@ public override void Validate() public PercentConfig() { } - public PercentConfig(global::Orb.Models.Plans.PercentConfig percentConfig) + public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } public PercentConfig(IReadOnlyDictionary rawData) @@ -7700,10 +7506,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 +7520,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 +7686,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 +7715,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 +7729,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 +7796,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 +7811,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 +7830,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 +7938,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 +8105,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 +8123,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 +8151,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 +8161,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 +8181,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 +8199,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 +8254,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 +8270,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 +8286,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 +8452,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 +8481,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 +8496,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 +8563,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 +8578,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Adjustment : JsonModel { /// @@ -8833,7 +8616,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 +8633,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 +8646,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 +9178,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 +9236,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 +9246,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 +9256,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 +9275,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 +9293,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 +9310,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/Prices/PriceCreateParams.cs b/src/Orb/Models/Prices/PriceCreateParams.cs index fcf7c47b7..be327efcc 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -653,7 +653,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 +755,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 +797,13 @@ public Body(NewFloatingCumulativeGroupedBulkPrice value, JsonElement? element = this._element = element; } - public Body( - global::Orb.Models.Prices.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public Body(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Body(global::Orb.Models.Prices.Minimum value, JsonElement? element = null) + public Body(Minimum value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -821,13 +815,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 +897,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 +1284,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 +1445,45 @@ 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; + value = this.Value as CumulativeGroupedAllocation; 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.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.Minimum` + /// // `value` is of type `Minimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Prices.Minimum? value) + public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) { - value = this.Value as global::Orb.Models.Prices.Minimum; + value = this.Value as Minimum; return value != null; } @@ -1520,45 +1512,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 +1569,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 +1586,18 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1616,7 +1606,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 +1623,18 @@ 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 minimum, System::Action newFloatingMinimumCompositePrice, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -1658,7 +1648,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 +1699,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 +1720,19 @@ 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: + case 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 +1758,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 +1775,18 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1805,7 +1795,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 +1824,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 +1846,11 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice, T > newFloatingCumulativeGroupedBulkPrice, - System::Func< - global::Orb.Models.Prices.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, + System::Func minimum, System::Func newFloatingMinimumCompositePrice, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -1874,7 +1858,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 +1884,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 +1901,11 @@ 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), + Minimum value => minimum(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 +1916,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 +1953,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 +1969,15 @@ 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(CumulativeGroupedAllocation value) => new(value); - public static implicit operator Body(global::Orb.Models.Prices.Minimum value) => new(value); + public static implicit operator Body(Minimum 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 @@ -2171,11 +2148,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2557,11 +2533,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2718,11 +2693,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2741,11 +2715,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2786,11 +2756,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2809,11 +2775,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2841,25 +2803,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 +2822,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 +2943,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 +3079,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 +3097,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 +3139,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 +3170,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 +3186,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 +3195,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 +3244,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 +3260,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 +3315,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 +3331,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 +3345,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 +3366,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 +3376,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 +3407,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 +3560,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 +3587,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 +3601,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 +3668,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 +3684,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 +3719,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 +3829,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 +3967,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 +3985,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 +3994,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 +4017,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 +4027,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 +4047,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 +4067,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 +4137,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -4255,8 +4154,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4264,18 +4163,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 +4330,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 +4359,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 +4374,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 +4441,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 +4457,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 +4479,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 +4602,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 +4740,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 +4758,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 +4767,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 +4790,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 +4800,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 +4820,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 +4840,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 +4910,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -5050,8 +4927,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5059,18 +4936,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 +5103,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 +5132,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 +5147,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 +5214,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,12 +5229,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.Minimum, - global::Orb.Models.Prices.MinimumFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Minimum : JsonModel { /// @@ -5409,14 +5274,12 @@ public required string ItemID /// /// Configuration for minimum pricing /// - public required global::Orb.Models.Prices.MinimumConfig MinimumConfig + public required MinimumConfig MinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("minimum_config"); } init { this._rawData.Set("minimum_config", value); } } @@ -5639,7 +5502,7 @@ public Minimum() this.ModelType = JsonSerializer.SerializeToElement("minimum"); } - public Minimum(global::Orb.Models.Prices.Minimum minimum) + public Minimum(Minimum minimum) : base(minimum) { } public Minimum(IReadOnlyDictionary rawData) @@ -5657,21 +5520,18 @@ public Minimum(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Minimum FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class MinimumFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.Minimum.FromRawUnchecked(rawData); + public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => + Minimum.FromRawUnchecked(rawData); } /// @@ -5736,12 +5596,7 @@ JsonSerializerOptions options /// /// Configuration for minimum pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.MinimumConfig, - global::Orb.Models.Prices.MinimumConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class MinimumConfig : JsonModel { /// @@ -5787,7 +5642,7 @@ public override void Validate() public MinimumConfig() { } - public MinimumConfig(global::Orb.Models.Prices.MinimumConfig minimumConfig) + public MinimumConfig(MinimumConfig minimumConfig) : base(minimumConfig) { } public MinimumConfig(IReadOnlyDictionary rawData) @@ -5803,10 +5658,8 @@ public MinimumConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -5819,12 +5672,11 @@ public MinimumConfig(string minimumAmount) } } -class MinimumConfigFromRaw : IFromRawJson +class MinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.MinimumConfig.FromRawUnchecked(rawData); + public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + MinimumConfig.FromRawUnchecked(rawData); } [JsonConverter(typeof(MinimumConversionRateConfigConverter))] @@ -6111,25 +5963,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.Percent, - global::Orb.Models.Prices.PercentFromRaw - >) -)] +[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); } } @@ -6189,14 +6034,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required global::Orb.Models.Prices.PercentConfig PercentConfig + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullClass("percent_config"); } init { this._rawData.Set("percent_config", value); } } @@ -6260,12 +6103,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.PercentConversionRateConfig? ConversionRateConfig + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6393,7 +6236,7 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Percent(global::Orb.Models.Prices.Percent percent) + public Percent(Percent percent) : base(percent) { } public Percent(IReadOnlyDictionary rawData) @@ -6411,27 +6254,24 @@ public Percent(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.Percent.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.PercentCadenceConverter))] +[JsonConverter(typeof(PercentCadenceConverter))] public enum PercentCadence { Annual, @@ -6442,9 +6282,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Prices.PercentCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6452,19 +6292,19 @@ 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), + "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.Prices.PercentCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -6472,12 +6312,12 @@ JsonSerializerOptions options 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", + 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)) ), @@ -6490,12 +6330,7 @@ JsonSerializerOptions options /// /// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.PercentConfig, - global::Orb.Models.Prices.PercentConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PercentConfig : JsonModel { /// @@ -6519,7 +6354,7 @@ public override void Validate() public PercentConfig() { } - public PercentConfig(global::Orb.Models.Prices.PercentConfig percentConfig) + public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } public PercentConfig(IReadOnlyDictionary rawData) @@ -6535,10 +6370,8 @@ public PercentConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -6551,15 +6384,14 @@ public PercentConfig(double percent) } } -class PercentConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.PercentConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Prices.PercentConversionRateConfigConverter))] +[JsonConverter(typeof(PercentConversionRateConfigConverter))] public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6718,11 +6550,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6747,7 +6579,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Prices.PercentConversionRateConfig? other) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -6761,10 +6593,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Prices.PercentConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6829,14 +6660,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.PercentConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.PercentConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -6844,25 +6675,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.EventOutput, - global::Orb.Models.Prices.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); } } @@ -6883,14 +6707,12 @@ public required string Currency /// /// Configuration for event_output pricing /// - public required global::Orb.Models.Prices.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); } } @@ -6993,12 +6815,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 +6953,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 +6971,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 +6999,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 +7009,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 +7029,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 +7047,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 +7102,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 +7118,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 +7134,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 +7300,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 +7329,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 +7344,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 +7411,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 171d505f2..1b8aaa012 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -258,12 +258,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 +326,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; @@ -1004,7 +1004,7 @@ public Price(PriceCumulativeGroupedAllocation value, JsonElement? element = null this._element = element; } - public Price(global::Orb.Models.Prices.PriceMinimum value, JsonElement? element = null) + public Price(PriceMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1667,24 +1667,22 @@ public bool TryPickCumulativeGroupedAllocation( /// /// 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.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.PriceMinimum` + /// // `value` is of type `PriceMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Prices.PriceMinimum? value - ) + public bool TryPickMinimum([NotNullWhen(true)] out PriceMinimum? value) { - value = this.Value as global::Orb.Models.Prices.PriceMinimum; + value = this.Value as PriceMinimum; return value != null; } @@ -1795,7 +1793,7 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, + /// (PriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PricePercent value) => {...}, /// (PriceEventOutput value) => {...} @@ -1832,7 +1830,7 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action minimum, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -1924,7 +1922,7 @@ public void Switch( case PriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Prices.PriceMinimum value: + case PriceMinimum value: minimum(value); break; case NewFloatingMinimumCompositePrice value: @@ -1984,7 +1982,7 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, + /// (PriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PricePercent value) => {...}, /// (PriceEventOutput value) => {...} @@ -2036,7 +2034,7 @@ public T Match( > newFloatingScalableMatrixWithTieredPricing, System::Func newFloatingCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, + System::Func minimum, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -2079,7 +2077,7 @@ public T Match( newFloatingScalableMatrixWithTieredPricing(value), NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - global::Orb.Models.Prices.PriceMinimum value => minimum(value), + PriceMinimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PricePercent value => percent(value), PriceEventOutput value => eventOutput(value), @@ -2087,126 +2085,78 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingUnitPrice value) => - new(value); + public static implicit operator Price(NewFloatingUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingTieredPrice value) => - new(value); + public static implicit operator Price(NewFloatingTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingBulkPrice value) => - new(value); + public static implicit operator Price(NewFloatingBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceBulkWithFilters value) => - new(value); + public static implicit operator Price(PriceBulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingMatrixPrice value) => - new(value); + public static implicit operator Price(NewFloatingMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewFloatingThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackageWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingPackageWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingBulkWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - PriceGroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(PriceGroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator Price(NewFloatingScalableMatrixWithUnitPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator Price(NewFloatingScalableMatrixWithTieredPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator Price(NewFloatingCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - PriceCumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(PriceCumulativeGroupedAllocation 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(PriceMinimum 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 @@ -2264,7 +2214,7 @@ public override void 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 +2228,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 @@ -2936,11 +2886,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3020,16 +2966,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,25 +5489,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.PriceMinimum, - global::Orb.Models.Prices.PriceMinimumFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PriceMinimum : 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); } } @@ -5694,12 +5629,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.PriceMinimumConversionRateConfig? ConversionRateConfig + public PriceMinimumConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5827,7 +5762,7 @@ public PriceMinimum() this.ModelType = JsonSerializer.SerializeToElement("minimum"); } - public PriceMinimum(global::Orb.Models.Prices.PriceMinimum priceMinimum) + public PriceMinimum(PriceMinimum priceMinimum) : base(priceMinimum) { } public PriceMinimum(IReadOnlyDictionary rawData) @@ -5845,27 +5780,24 @@ public PriceMinimum(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.PriceMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PriceMinimumFromRaw : IFromRawJson +class PriceMinimumFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.PriceMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.PriceMinimum.FromRawUnchecked(rawData); + public PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => + PriceMinimum.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.PriceMinimumCadenceConverter))] +[JsonConverter(typeof(PriceMinimumCadenceConverter))] public enum PriceMinimumCadence { Annual, @@ -5876,10 +5808,9 @@ public enum PriceMinimumCadence Custom, } -sealed class PriceMinimumCadenceConverter - : JsonConverter +sealed class PriceMinimumCadenceConverter : JsonConverter { - public override global::Orb.Models.Prices.PriceMinimumCadence Read( + public override PriceMinimumCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5887,19 +5818,19 @@ 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), + "annual" => PriceMinimumCadence.Annual, + "semi_annual" => PriceMinimumCadence.SemiAnnual, + "monthly" => PriceMinimumCadence.Monthly, + "quarterly" => PriceMinimumCadence.Quarterly, + "one_time" => PriceMinimumCadence.OneTime, + "custom" => PriceMinimumCadence.Custom, + _ => (PriceMinimumCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.PriceMinimumCadence value, + PriceMinimumCadence value, JsonSerializerOptions options ) { @@ -5907,12 +5838,12 @@ JsonSerializerOptions options 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", + PriceMinimumCadence.Annual => "annual", + PriceMinimumCadence.SemiAnnual => "semi_annual", + PriceMinimumCadence.Monthly => "monthly", + PriceMinimumCadence.Quarterly => "quarterly", + PriceMinimumCadence.OneTime => "one_time", + PriceMinimumCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6013,7 +5944,7 @@ IReadOnlyDictionary rawData ) => PriceMinimumMinimumConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Prices.PriceMinimumConversionRateConfigConverter))] +[JsonConverter(typeof(PriceMinimumConversionRateConfigConverter))] public record class PriceMinimumConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6172,11 +6103,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.PriceMinimumConversionRateConfig( + public static implicit operator PriceMinimumConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.PriceMinimumConversionRateConfig( + public static implicit operator PriceMinimumConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6201,7 +6132,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Prices.PriceMinimumConversionRateConfig? other) + public virtual bool Equals(PriceMinimumConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -6216,9 +6147,9 @@ public override string ToString() => } sealed class PriceMinimumConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.PriceMinimumConversionRateConfig? Read( + public override PriceMinimumConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6283,14 +6214,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.PriceMinimumConversionRateConfig(element); + return new PriceMinimumConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.PriceMinimumConversionRateConfig value, + PriceMinimumConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs index 943363b6f..cac383741 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs @@ -72,14 +72,12 @@ 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); } } @@ -142,7 +140,7 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt } } -[JsonConverter(typeof(global::Orb.Models.SubscriptionChanges.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Pending, @@ -150,9 +148,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 +158,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/Subscriptions/DiscountOverride.cs b/src/Orb/Models/Subscriptions/DiscountOverride.cs index 642d8032d..a160cbe7b 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 5689bada7..74a121d1f 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 dab88d879..2661dfa47 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 fbc2978a4..f3c60a36e 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 7d50e2604..cb71dda29 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 cf6893503..b4d29c042 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 3f6744267..577d98a6f 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 42f095046..dedb78918 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 77d37738f..7180a9f90 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 6f2c58806..5436dbabf 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 c9ee665e1..5ddb44a80 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 7b742fcad..2fbc8b53f 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 f82c1228b..a241b6118 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 7e390a378..304d377ee 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 369b5f6fa..d93a3cf8d 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 8b368dc93..b20a1d51a 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 b343c95c3..3e3342e21 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 b279882c4..6d31b48f7 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 9cfb82003..cef8a9616 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 76992d4a8..ba93e752f 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 2a11c3c49..33d03f2e8 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/SubscriptionCreateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs index 8313b8006..8fa21ef64 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -812,14 +812,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 +898,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 +1197,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 +1232,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 +1246,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 +1373,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 +1498,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 +1589,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; @@ -2171,10 +2161,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 +2227,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 +2263,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 +2311,13 @@ public Price(NewSubscriptionCumulativeGroupedBulkPrice value, JsonElement? eleme this._element = element; } - public Price( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public Price(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Subscriptions.Minimum value, JsonElement? element = null) + public Price(Minimum value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2351,13 +2329,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 +2413,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 +2664,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 +2800,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 +2961,45 @@ 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 + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Subscriptions.CumulativeGroupedAllocation; + value = this.Value as CumulativeGroupedAllocation; 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.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.Minimum` + /// // `value` is of type `Minimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.Minimum? value - ) + public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) { - value = this.Value as global::Orb.Models.Subscriptions.Minimum; + value = this.Value as Minimum; return value != null; } @@ -3056,47 +3028,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 +3085,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 +3096,24 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3154,7 +3122,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 +3133,24 @@ 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 minimum, System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -3196,7 +3164,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 +3197,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 +3215,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 +3236,19 @@ 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: + case 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 +3274,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 +3285,24 @@ 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) => {...}, + /// (Minimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3343,7 +3311,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 +3334,7 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice, T > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, + System::Func tieredWithProration, System::Func newSubscriptionUnitWithProration, System::Func newSubscriptionGroupedAllocation, System::Func newSubscriptionBulkWithProration, @@ -3378,10 +3346,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 +3371,11 @@ public T Match( NewSubscriptionCumulativeGroupedBulkPrice, T > newSubscriptionCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, + System::Func minimum, System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -3421,7 +3383,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 +3401,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 +3409,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 +3426,96 @@ 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), + Minimum value => minimum(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 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(CumulativeGroupedAllocation 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(Minimum 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 @@ -3666,7 +3578,7 @@ public override void 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 +3592,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 +3683,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4022,11 +3933,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4160,11 +4070,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4321,11 +4230,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4344,11 +4252,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -4390,11 +4294,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -4413,11 +4313,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -4434,40 +4330,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 +4360,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 +4468,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 +4633,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 +4651,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 +4693,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 +4724,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 +4740,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 +4749,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 +4798,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 +4814,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 +4869,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 +4885,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 +4899,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 +4920,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 +4930,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 +4961,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 +5114,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 +5141,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 +5155,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 +5222,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 +5237,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 +5297,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 +5368,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 +5535,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 +5553,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 +5562,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 +5583,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 +5593,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 +5613,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 +5632,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 +5640,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 +5669,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 +5685,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 +5694,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 +5753,7 @@ public override void Validate() public TieredWithProrationConfigTier() { } public TieredWithProrationConfigTier( - global::Orb.Models.Subscriptions.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } @@ -5952,8 +5770,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 +5779,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 +5946,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 +5975,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 +5990,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 +6057,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 +6073,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 +6095,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 +6205,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 +6372,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 +6390,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 +6399,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 +6422,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 +6432,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 +6452,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 +6472,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 +6542,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -6781,8 +6559,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6790,21 +6568,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 +6735,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 +6764,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 +6779,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 +6846,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 +6862,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 +6884,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 +6994,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 +7161,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 +7179,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 +7188,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 +7211,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 +7221,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 +7241,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 +7261,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 +7331,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -7613,8 +7348,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7622,21 +7357,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 +7524,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 +7553,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 +7568,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 +7635,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,12 +7650,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Minimum, - global::Orb.Models.Subscriptions.MinimumFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Minimum : JsonModel { /// @@ -7962,14 +7682,12 @@ public required string ItemID /// /// Configuration for minimum pricing /// - public required global::Orb.Models.Subscriptions.MinimumConfig MinimumConfig + public required MinimumConfig MinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("minimum_config"); } init { this._rawData.Set("minimum_config", value); } } @@ -8221,7 +7939,7 @@ public Minimum() this.ModelType = JsonSerializer.SerializeToElement("minimum"); } - public Minimum(global::Orb.Models.Subscriptions.Minimum minimum) + public Minimum(Minimum minimum) : base(minimum) { } public Minimum(IReadOnlyDictionary rawData) @@ -8239,21 +7957,18 @@ public Minimum(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Minimum FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class MinimumFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Minimum.FromRawUnchecked(rawData); + public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => + Minimum.FromRawUnchecked(rawData); } /// @@ -8318,12 +8033,7 @@ JsonSerializerOptions options /// /// Configuration for minimum pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MinimumConfig, - global::Orb.Models.Subscriptions.MinimumConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class MinimumConfig : JsonModel { /// @@ -8369,7 +8079,7 @@ public override void Validate() public MinimumConfig() { } - public MinimumConfig(global::Orb.Models.Subscriptions.MinimumConfig minimumConfig) + public MinimumConfig(MinimumConfig minimumConfig) : base(minimumConfig) { } public MinimumConfig(IReadOnlyDictionary rawData) @@ -8385,10 +8095,8 @@ public MinimumConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -8401,12 +8109,11 @@ public MinimumConfig(string minimumAmount) } } -class MinimumConfigFromRaw : IFromRawJson +class MinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MinimumConfig.FromRawUnchecked(rawData); + public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + MinimumConfig.FromRawUnchecked(rawData); } [JsonConverter(typeof(MinimumConversionRateConfigConverter))] @@ -8693,25 +8400,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Percent, - global::Orb.Models.Subscriptions.PercentFromRaw - >) -)] +[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); } } @@ -8758,14 +8458,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required global::Orb.Models.Subscriptions.PercentConfig PercentConfig + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullClass("percent_config"); } init { this._rawData.Set("percent_config", value); } } @@ -8829,12 +8527,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 PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8991,7 +8689,7 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Percent(global::Orb.Models.Subscriptions.Percent percent) + public Percent(Percent percent) : base(percent) { } public Percent(IReadOnlyDictionary rawData) @@ -9009,27 +8707,24 @@ public Percent(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Percent.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentCadenceConverter))] +[JsonConverter(typeof(PercentCadenceConverter))] public enum PercentCadence { Annual, @@ -9040,10 +8735,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9051,19 +8745,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" => 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.Subscriptions.PercentCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -9071,12 +8765,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", + 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)) ), @@ -9089,12 +8783,7 @@ JsonSerializerOptions options /// /// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.PercentConfig, - global::Orb.Models.Subscriptions.PercentConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PercentConfig : JsonModel { /// @@ -9118,7 +8807,7 @@ public override void Validate() public PercentConfig() { } - public PercentConfig(global::Orb.Models.Subscriptions.PercentConfig percentConfig) + public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } public PercentConfig(IReadOnlyDictionary rawData) @@ -9134,10 +8823,8 @@ public PercentConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -9150,15 +8837,14 @@ public PercentConfig(double percent) } } -class PercentConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.PercentConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentConversionRateConfigConverter))] +[JsonConverter(typeof(PercentConversionRateConfigConverter))] public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9317,11 +9003,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9346,7 +9032,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Subscriptions.PercentConversionRateConfig? other) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9360,10 +9046,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9428,14 +9113,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.PercentConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.PercentConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -9443,25 +9128,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.EventOutput, - global::Orb.Models.Subscriptions.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); } } @@ -9469,14 +9147,12 @@ public sealed record class EventOutput : JsonModel /// /// Configuration for event_output pricing /// - public required global::Orb.Models.Subscriptions.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); } } @@ -9579,12 +9255,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9746,7 +9422,7 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public EventOutput(global::Orb.Models.Subscriptions.EventOutput eventOutput) + public EventOutput(EventOutput eventOutput) : base(eventOutput) { } public EventOutput(IReadOnlyDictionary rawData) @@ -9764,27 +9440,24 @@ public EventOutput(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.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.Subscriptions.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutput.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputCadenceConverter))] +[JsonConverter(typeof(EventOutputCadenceConverter))] public enum EventOutputCadence { Annual, @@ -9795,10 +9468,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.EventOutputCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9806,19 +9478,19 @@ 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), + "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.EventOutputCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -9826,12 +9498,12 @@ JsonSerializerOptions options 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", + 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)) ), @@ -9844,12 +9516,7 @@ JsonSerializerOptions options /// /// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.EventOutputConfig, - global::Orb.Models.Subscriptions.EventOutputConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutputConfig : JsonModel { /// @@ -9904,7 +9571,7 @@ public override void Validate() public EventOutputConfig() { } - public EventOutputConfig(global::Orb.Models.Subscriptions.EventOutputConfig eventOutputConfig) + public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } public EventOutputConfig(IReadOnlyDictionary rawData) @@ -9920,8 +9587,8 @@ public EventOutputConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9936,15 +9603,14 @@ public EventOutputConfig(string unitRatingKey) } } -class EventOutputConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutputConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputConversionRateConfigConverter))] +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -10103,11 +9769,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -10132,9 +9798,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? other - ) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -10149,9 +9813,9 @@ public override string ToString() => } sealed class EventOutputConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -10216,16 +9880,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - element - ); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionListParams.cs b/src/Orb/Models/Subscriptions/SubscriptionListParams.cs index e2d4fbec0..4c5026d58 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionListParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionListParams.cs @@ -151,14 +151,12 @@ 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); } } @@ -219,7 +217,7 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt } } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, @@ -227,9 +225,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 +235,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 e59a81ef6..ae080e213 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -349,18 +349,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 +410,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 +1007,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 +1036,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 +1050,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 +1130,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 +1627,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 +1666,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 +1682,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 +1691,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); } /// diff --git a/src/Orb/Services/Coupons/ISubscriptionService.cs b/src/Orb/Services/Coupons/ISubscriptionService.cs index cbf3ddb5b..a86ee0cc8 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 6bfe328bf..fe70b76d3 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) From 8a870218bc1eebf9e4430ed69fedc206e7b9f25c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 22:03:03 +0000 Subject: [PATCH 04/39] feat(client): add Equals and ToString to params --- .../AlertCreateForCustomerParamsTest.cs | 16 + ...lertCreateForExternalCustomerParamsTest.cs | 16 + .../AlertCreateForSubscriptionParamsTest.cs | 16 + .../Models/Alerts/AlertDisableParamsTest.cs | 14 + .../Models/Alerts/AlertEnableParamsTest.cs | 14 + .../Models/Alerts/AlertListParamsTest.cs | 21 ++ .../Models/Alerts/AlertRetrieveParamsTest.cs | 10 + .../Models/Alerts/AlertUpdateParamsTest.cs | 14 + .../Beta/BetaCreatePlanVersionParamsTest.cs | 213 ++++++++++++++ .../Beta/BetaFetchPlanVersionParamsTest.cs | 10 + .../BetaSetDefaultPlanVersionParamsTest.cs | 10 + ...ternalPlanIDCreatePlanVersionParamsTest.cs | 213 ++++++++++++++ ...xternalPlanIDFetchPlanVersionParamsTest.cs | 14 + ...alPlanIDSetDefaultPlanVersionParamsTest.cs | 14 + .../Models/Coupons/CouponArchiveParamsTest.cs | 10 + .../Models/Coupons/CouponCreateParamsTest.cs | 16 + .../Models/Coupons/CouponFetchParamsTest.cs | 10 + .../Models/Coupons/CouponListParamsTest.cs | 16 + .../SubscriptionListParamsTest.cs | 15 + .../CreditBlockDeleteParamsTest.cs | 10 + .../CreditBlockRetrieveParamsTest.cs | 10 + .../CreditNotes/CreditNoteCreateParamsTest.cs | 26 ++ .../CreditNotes/CreditNoteFetchParamsTest.cs | 10 + .../CreditNotes/CreditNoteListParamsTest.cs | 18 ++ .../BalanceTransactionCreateParamsTest.cs | 16 + .../BalanceTransactionListParamsTest.cs | 19 ++ .../Costs/CostListByExternalIDParamsTest.cs | 17 ++ .../Customers/Costs/CostListParamsTest.cs | 17 ++ .../CreditListByExternalIDParamsTest.cs | 17 ++ .../Customers/Credits/CreditListParamsTest.cs | 17 ++ ...LedgerCreateEntryByExternalIDParamsTest.cs | 43 +++ .../Ledger/LedgerCreateEntryParamsTest.cs | 42 +++ .../LedgerListByExternalIDParamsTest.cs | 23 ++ .../Credits/Ledger/LedgerListParamsTest.cs | 23 ++ .../TopUpCreateByExternalIDParamsTest.cs | 27 ++ .../Credits/TopUps/TopUpCreateParamsTest.cs | 27 ++ .../TopUpDeleteByExternalIDParamsTest.cs | 14 + .../Credits/TopUps/TopUpDeleteParamsTest.cs | 14 + .../TopUps/TopUpListByExternalIDParamsTest.cs | 15 + .../Credits/TopUps/TopUpListParamsTest.cs | 15 + .../Customers/CustomerCreateParamsTest.cs | 84 ++++++ .../Customers/CustomerDeleteParamsTest.cs | 10 + .../CustomerFetchByExternalIDParamsTest.cs | 13 + .../Customers/CustomerFetchParamsTest.cs | 10 + .../Customers/CustomerListParamsTest.cs | 18 ++ ...omGatewayByExternalCustomerIDParamsTest.cs | 13 + ...SyncPaymentMethodsFromGatewayParamsTest.cs | 13 + .../CustomerUpdateByExternalIDParamsTest.cs | 85 ++++++ .../Customers/CustomerUpdateParamsTest.cs | 85 ++++++ .../DimensionalPriceGroupCreateParamsTest.cs | 17 ++ .../DimensionalPriceGroupListParamsTest.cs | 10 + ...DimensionalPriceGroupRetrieveParamsTest.cs | 13 + .../DimensionalPriceGroupUpdateParamsTest.cs | 15 + ...mensionalPriceGroupIDRetrieveParamsTest.cs | 13 + ...DimensionalPriceGroupIDUpdateParamsTest.cs | 15 + .../Backfills/BackfillCloseParamsTest.cs | 10 + .../Backfills/BackfillCreateParamsTest.cs | 19 ++ .../Backfills/BackfillFetchParamsTest.cs | 10 + .../Backfills/BackfillListParamsTest.cs | 10 + .../Backfills/BackfillRevertParamsTest.cs | 10 + .../Models/Events/EventDeprecateParamsTest.cs | 10 + .../Models/Events/EventIngestParamsTest.cs | 29 ++ .../Models/Events/EventSearchParamsTest.cs | 15 + .../Models/Events/EventUpdateParamsTest.cs | 21 ++ .../Events/Volume/VolumeListParamsTest.cs | 16 + .../InvoiceLineItemCreateParamsTest.cs | 19 ++ .../Invoices/InvoiceCreateParamsTest.cs | 50 ++++ .../InvoiceDeleteLineItemParamsTest.cs | 14 + .../Models/Invoices/InvoiceFetchParamsTest.cs | 10 + .../InvoiceFetchUpcomingParamsTest.cs | 10 + .../Models/Invoices/InvoiceIssueParamsTest.cs | 10 + .../Models/Invoices/InvoiceListParamsTest.cs | 31 ++ .../Invoices/InvoiceListSummaryParamsTest.cs | 32 ++ .../Invoices/InvoiceMarkPaidParamsTest.cs | 16 + .../Models/Invoices/InvoicePayParamsTest.cs | 10 + .../Invoices/InvoiceUpdateParamsTest.cs | 17 ++ .../Models/Invoices/InvoiceVoidParamsTest.cs | 10 + .../Models/Items/ItemArchiveParamsTest.cs | 10 + .../Models/Items/ItemCreateParamsTest.cs | 14 + .../Models/Items/ItemFetchParamsTest.cs | 10 + .../Models/Items/ItemListParamsTest.cs | 10 + .../Models/Items/ItemUpdateParamsTest.cs | 23 ++ .../Models/Metrics/MetricCreateParamsTest.cs | 17 ++ .../Models/Metrics/MetricFetchParamsTest.cs | 10 + .../Models/Metrics/MetricListParamsTest.cs | 18 ++ .../Models/Metrics/MetricUpdateParamsTest.cs | 14 + .../ExternalPlanIDFetchParamsTest.cs | 10 + .../ExternalPlanIDUpdateParamsTest.cs | 15 + .../Migrations/MigrationCancelParamsTest.cs | 14 + .../Migrations/MigrationListParamsTest.cs | 15 + .../Migrations/MigrationRetrieveParamsTest.cs | 14 + .../Models/Plans/PlanCreateParamsTest.cs | 126 ++++++++ .../Models/Plans/PlanFetchParamsTest.cs | 10 + .../Models/Plans/PlanListParamsTest.cs | 19 ++ .../Models/Plans/PlanUpdateParamsTest.cs | 15 + .../ExternalPriceIDFetchParamsTest.cs | 10 + .../ExternalPriceIDUpdateParamsTest.cs | 14 + .../Models/Prices/PriceCreateParamsTest.cs | 50 ++++ .../Prices/PriceEvaluateMultipleParamsTest.cs | 64 ++++ .../Models/Prices/PriceEvaluateParamsTest.cs | 19 ++ .../PriceEvaluatePreviewEventsParamsTest.cs | 78 +++++ .../Models/Prices/PriceFetchParamsTest.cs | 10 + .../Models/Prices/PriceListParamsTest.cs | 10 + .../Models/Prices/PriceUpdateParamsTest.cs | 14 + .../SubscriptionChangeApplyParamsTest.cs | 19 ++ .../SubscriptionChangeCancelParamsTest.cs | 13 + .../SubscriptionChangeListParamsTest.cs | 17 ++ .../SubscriptionChangeRetrieveParamsTest.cs | 13 + .../SubscriptionCancelParamsTest.cs | 16 + .../SubscriptionCreateParamsTest.cs | 274 ++++++++++++++++++ .../SubscriptionFetchCostsParamsTest.cs | 17 ++ .../SubscriptionFetchParamsTest.cs | 10 + .../SubscriptionFetchScheduleParamsTest.cs | 19 ++ .../SubscriptionFetchUsageParamsTest.cs | 23 ++ .../SubscriptionListParamsTest.cs | 23 ++ .../SubscriptionPriceIntervalsParamsTest.cs | 159 ++++++++++ .../SubscriptionRedeemCouponParamsTest.cs | 18 ++ ...ubscriptionSchedulePlanChangeParamsTest.cs | 269 +++++++++++++++++ .../SubscriptionTriggerPhaseParamsTest.cs | 15 + ...riptionUnscheduleCancellationParamsTest.cs | 13 + ...heduleFixedFeeQuantityUpdatesParamsTest.cs | 14 + ...nUnschedulePendingPlanChangesParamsTest.cs | 13 + ...riptionUpdateFixedFeeQuantityParamsTest.cs | 18 ++ .../SubscriptionUpdateParamsTest.cs | 18 ++ .../SubscriptionUpdateTrialParamsTest.cs | 15 + .../Alerts/AlertCreateForCustomerParams.cs | 38 ++- .../AlertCreateForExternalCustomerParams.cs | 41 ++- .../AlertCreateForSubscriptionParams.cs | 38 ++- src/Orb/Models/Alerts/AlertDisableParams.cs | 39 ++- src/Orb/Models/Alerts/AlertEnableParams.cs | 39 ++- src/Orb/Models/Alerts/AlertListParams.cs | 34 ++- src/Orb/Models/Alerts/AlertRetrieveParams.cs | 36 ++- src/Orb/Models/Alerts/AlertUpdateParams.cs | 41 ++- .../Beta/BetaCreatePlanVersionParams.cs | 38 ++- .../Models/Beta/BetaFetchPlanVersionParams.cs | 38 ++- .../Beta/BetaSetDefaultPlanVersionParams.cs | 38 ++- .../ExternalPlanIDCreatePlanVersionParams.cs | 38 ++- .../ExternalPlanIDFetchPlanVersionParams.cs | 38 ++- ...ternalPlanIDSetDefaultPlanVersionParams.cs | 38 ++- src/Orb/Models/Coupons/CouponArchiveParams.cs | 36 ++- src/Orb/Models/Coupons/CouponCreateParams.cs | 36 ++- src/Orb/Models/Coupons/CouponFetchParams.cs | 36 ++- src/Orb/Models/Coupons/CouponListParams.cs | 34 ++- .../Subscriptions/SubscriptionListParams.cs | 36 ++- .../CreditBlocks/CreditBlockDeleteParams.cs | 36 ++- .../CreditBlocks/CreditBlockRetrieveParams.cs | 36 ++- .../CreditNotes/CreditNoteCreateParams.cs | 36 ++- .../CreditNotes/CreditNoteFetchParams.cs | 36 ++- .../CreditNotes/CreditNoteListParams.cs | 34 ++- .../BalanceTransactionCreateParams.cs | 38 ++- .../BalanceTransactionListParams.cs | 36 ++- .../Costs/CostListByExternalIDParams.cs | 39 ++- .../Models/Customers/Costs/CostListParams.cs | 36 ++- .../Credits/CreditListByExternalIDParams.cs | 39 ++- .../Customers/Credits/CreditListParams.cs | 36 ++- .../LedgerCreateEntryByExternalIDParams.cs | 41 ++- .../Credits/Ledger/LedgerCreateEntryParams.cs | 38 ++- .../Ledger/LedgerListByExternalIDParams.cs | 39 ++- .../Credits/Ledger/LedgerListParams.cs | 36 ++- .../TopUps/TopUpCreateByExternalIDParams.cs | 41 ++- .../Credits/TopUps/TopUpCreateParams.cs | 38 ++- .../TopUps/TopUpDeleteByExternalIDParams.cs | 38 ++- .../Credits/TopUps/TopUpDeleteParams.cs | 38 ++- .../TopUps/TopUpListByExternalIDParams.cs | 39 ++- .../Credits/TopUps/TopUpListParams.cs | 36 ++- .../Models/Customers/CustomerCreateParams.cs | 36 ++- .../Models/Customers/CustomerDeleteParams.cs | 36 ++- .../CustomerFetchByExternalIDParams.cs | 39 ++- .../Models/Customers/CustomerFetchParams.cs | 36 ++- .../Models/Customers/CustomerListParams.cs | 34 ++- ...dsFromGatewayByExternalCustomerIDParams.cs | 42 ++- ...omerSyncPaymentMethodsFromGatewayParams.cs | 36 ++- .../CustomerUpdateByExternalIDParams.cs | 38 ++- .../Models/Customers/CustomerUpdateParams.cs | 38 ++- .../DimensionalPriceGroupCreateParams.cs | 36 ++- .../DimensionalPriceGroupListParams.cs | 34 ++- .../DimensionalPriceGroupRetrieveParams.cs | 39 ++- .../DimensionalPriceGroupUpdateParams.cs | 41 ++- ...alDimensionalPriceGroupIDRetrieveParams.cs | 39 ++- ...rnalDimensionalPriceGroupIDUpdateParams.cs | 41 ++- .../Events/Backfills/BackfillCloseParams.cs | 36 ++- .../Events/Backfills/BackfillCreateParams.cs | 36 ++- .../Events/Backfills/BackfillFetchParams.cs | 36 ++- .../Events/Backfills/BackfillListParams.cs | 34 ++- .../Events/Backfills/BackfillRevertParams.cs | 36 ++- src/Orb/Models/Events/EventDeprecateParams.cs | 36 ++- src/Orb/Models/Events/EventIngestParams.cs | 36 ++- src/Orb/Models/Events/EventSearchParams.cs | 36 ++- src/Orb/Models/Events/EventUpdateParams.cs | 38 ++- .../Models/Events/Volume/VolumeListParams.cs | 34 ++- .../InvoiceLineItemCreateParams.cs | 36 ++- .../Models/Invoices/InvoiceCreateParams.cs | 36 ++- .../Invoices/InvoiceDeleteLineItemParams.cs | 38 ++- src/Orb/Models/Invoices/InvoiceFetchParams.cs | 36 ++- .../Invoices/InvoiceFetchUpcomingParams.cs | 34 ++- src/Orb/Models/Invoices/InvoiceIssueParams.cs | 38 ++- src/Orb/Models/Invoices/InvoiceListParams.cs | 34 ++- .../Invoices/InvoiceListSummaryParams.cs | 34 ++- .../Models/Invoices/InvoiceMarkPaidParams.cs | 38 ++- src/Orb/Models/Invoices/InvoicePayParams.cs | 36 ++- .../Models/Invoices/InvoiceUpdateParams.cs | 38 ++- src/Orb/Models/Invoices/InvoiceVoidParams.cs | 36 ++- src/Orb/Models/Items/ItemArchiveParams.cs | 36 ++- src/Orb/Models/Items/ItemCreateParams.cs | 36 ++- src/Orb/Models/Items/ItemFetchParams.cs | 36 ++- src/Orb/Models/Items/ItemListParams.cs | 34 ++- src/Orb/Models/Items/ItemUpdateParams.cs | 38 ++- src/Orb/Models/Metrics/MetricCreateParams.cs | 36 ++- src/Orb/Models/Metrics/MetricFetchParams.cs | 36 ++- src/Orb/Models/Metrics/MetricListParams.cs | 34 ++- src/Orb/Models/Metrics/MetricUpdateParams.cs | 38 ++- .../ExternalPlanIDFetchParams.cs | 36 ++- .../ExternalPlanIDUpdateParams.cs | 41 ++- .../Plans/Migrations/MigrationCancelParams.cs | 38 ++- .../Plans/Migrations/MigrationListParams.cs | 36 ++- .../Migrations/MigrationRetrieveParams.cs | 38 ++- src/Orb/Models/Plans/PlanCreateParams.cs | 36 ++- src/Orb/Models/Plans/PlanFetchParams.cs | 36 ++- src/Orb/Models/Plans/PlanListParams.cs | 34 ++- src/Orb/Models/Plans/PlanUpdateParams.cs | 38 ++- .../ExternalPriceIDFetchParams.cs | 38 ++- .../ExternalPriceIDUpdateParams.cs | 40 ++- src/Orb/Models/Prices/PriceCreateParams.cs | 36 ++- .../Prices/PriceEvaluateMultipleParams.cs | 36 ++- src/Orb/Models/Prices/PriceEvaluateParams.cs | 38 ++- .../PriceEvaluatePreviewEventsParams.cs | 36 ++- src/Orb/Models/Prices/PriceFetchParams.cs | 36 ++- src/Orb/Models/Prices/PriceListParams.cs | 34 ++- src/Orb/Models/Prices/PriceUpdateParams.cs | 38 ++- .../SubscriptionChangeApplyParams.cs | 41 ++- .../SubscriptionChangeCancelParams.cs | 39 ++- .../SubscriptionChangeListParams.cs | 34 ++- .../SubscriptionChangeRetrieveParams.cs | 39 ++- .../Subscriptions/SubscriptionCancelParams.cs | 38 ++- .../Subscriptions/SubscriptionCreateParams.cs | 36 ++- .../SubscriptionFetchCostsParams.cs | 36 ++- .../Subscriptions/SubscriptionFetchParams.cs | 36 ++- .../SubscriptionFetchScheduleParams.cs | 36 ++- .../SubscriptionFetchUsageParams.cs | 36 ++- .../Subscriptions/SubscriptionListParams.cs | 34 ++- .../SubscriptionPriceIntervalsParams.cs | 38 ++- .../SubscriptionRedeemCouponParams.cs | 38 ++- .../SubscriptionSchedulePlanChangeParams.cs | 38 ++- .../SubscriptionTriggerPhaseParams.cs | 38 ++- ...ubscriptionUnscheduleCancellationParams.cs | 36 ++- ...UnscheduleFixedFeeQuantityUpdatesParams.cs | 38 ++- ...ptionUnschedulePendingPlanChangesParams.cs | 36 ++- ...ubscriptionUpdateFixedFeeQuantityParams.cs | 38 ++- .../Subscriptions/SubscriptionUpdateParams.cs | 38 ++- .../SubscriptionUpdateTrialParams.cs | 38 ++- src/Orb/Models/TopLevel/TopLevelPingParams.cs | 34 ++- 251 files changed, 8036 insertions(+), 127 deletions(-) diff --git a/src/Orb.Tests/Models/Alerts/AlertCreateForCustomerParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertCreateForCustomerParamsTest.cs index de8aebe82..ff402e478 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 430dc7d5a..78f0f8726 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 2ebc435f4..a65c61521 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 c17bac784..f62600f98 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 ce7dad90d..83486a8f1 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 c5fba8826..a3f33cdbc 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 1f4af2e6e..a0f190750 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 dd2c0ffba..1184a2252 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 06be5d09c..f822bc692 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 diff --git a/src/Orb.Tests/Models/Beta/BetaFetchPlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaFetchPlanVersionParamsTest.cs index a403e952b..f514a861d 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 d612d3e1f..50387028d 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 5d60504a6..4754a003b 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 diff --git a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParamsTest.cs index 7663b346d..5d64d6d49 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 a8067fbc3..68dbc82dd 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 cbc8c846c..5ad2b2d7d 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 ce6219e7b..8a98bf6f6 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 a5bf9eb40..b0a9fb78d 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 48ae0f559..5345b1453 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 a327c6608..e823286e6 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 e601cd0f7..7561c55e5 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 4ac40507a..a9b6654fa 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 b4d7d46ad..052af5b34 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 db9882485..3870fde69 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 2ada07518..048ded864 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 b469a1d42..3ed4af60c 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 a008e6061..29d3c4dd1 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 740995ac4..4bf55259d 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 f828062a0..8d6bcb182 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 5f8fe537f..7d5128620 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 b00d7ced7..422638a84 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 52d83f735..03ea7b755 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 a21e4975d..0128774fe 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 401a72247..2c69e131f 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 b46b360a4..86869db47 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 dbd7568a7..14bad1227 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 9fa88d82d..3d36144c9 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 825b47856..f9418b5e4 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 28d6de9e7..a404aa141 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 9e1131b1c..515bacfe4 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 5ba2f6b9d..90e31cc56 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 578e36389..18e20a11e 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 5c2adf1cb..c4909f1db 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 efdeec117..e35194d3c 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 7cd3f3984..13c6b35ed 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 c88cd0d44..718f1fff8 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 84558ee8e..4eff7bae2 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 25cf51231..fe9b6b4b9 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 f30346cab..fac4b6611 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 7df9fd352..42a77ed14 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 32314559e..9ba874e35 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 318e099cd..821f87ffb 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 a66eb9aa3..3a5879a73 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 aa19e39ce..6155b2642 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 e46e4199c..61a175a22 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 88f44fe35..c56185c7e 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 f374f30bb..3e7bd3230 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 8c2c0c2a0..26e194203 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 1ff26646d..b7129229b 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 3536b9c33..f6aed51ef 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 159db037e..6d4815964 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 f14fd39de..8a3fc8e85 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 09865dfd0..10b90d67e 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 32c0a7a92..bc3b222a8 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 481628c94..ef7056eb8 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 ef1c5f253..8f7ab9c8d 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 8822a16f9..fe05cf32b 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 30ca312ff..14a974edf 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs @@ -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 Invoices::InvoiceCreateParams + { + Currency = "USD", + InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + EndDate = "2023-09-22", + ItemID = "4khy3nwzktxv7", + ModelType = Invoices::ModelType.Unit, + Name = "Line Item Name", + Quantity = 1, + StartDate = "2023-09-22", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }, + ], + CustomerID = "4khy3nwzktxv7", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = 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, + }; + + Invoices::InvoiceCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class LineItemTest : TestBase diff --git a/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs index 793a2da76..1eb1692e7 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 dce86935b..2f2def2e4 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 d6ae79ff9..8ee1a0ed0 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 1e0133e9f..dcb8bd7ec 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 bf9705472..d8699ca2e 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 60d010678..3b73526a7 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs @@ -298,6 +298,38 @@ 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, + StatusValue = [StatusModel.Draft], + SubscriptionID = "subscription_id", + }; + + InvoiceListSummaryParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class InvoiceListSummaryParamsDateTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Invoices/InvoiceMarkPaidParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceMarkPaidParamsTest.cs index d7664ee59..103611144 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 a79bf7306..0b09b26f7 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 91b236e28..b7ad75e42 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 9f4ff4f43..87d032b43 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 e06cc4165..324cc8218 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 ce453450c..d663746ce 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 a3f2d6209..b3e48dc13 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 20b1046ac..0f3955893 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 8d3b688be..1def788ec 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 3bcadb995..6173d79ca 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 e0d5105e7..9d69910df 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 0b207e297..311c0cfda 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 776ace1b8..96c9499a3 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 c8b716689..d6ccc6f92 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 969cf7e54..24391069c 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 fe1d3adc9..c62a7c6f2 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 52ca2129b..9cb3a5619 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 df81607ac..0b2d915a8 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 0ff196c74..55050d81f 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 diff --git a/src/Orb.Tests/Models/Plans/PlanFetchParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanFetchParamsTest.cs index a7bf5d800..7c0e0b104 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 9e211ee35..edd633d68 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 56911877b..d6940400f 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/Prices/ExternalPriceID/ExternalPriceIDFetchParamsTest.cs b/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParamsTest.cs index 738921ad3..623576670 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 29268eacd..f3fff77c2 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 494a3583b..7eddcfa33 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 diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs index e37fc01b4..6ff36cf0c 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 diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs index 43543de01..c3660fc07 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 1f1efee63..35c831070 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 diff --git a/src/Orb.Tests/Models/Prices/PriceFetchParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceFetchParamsTest.cs index 4c0d55547..49c3495a0 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 4d2939a6a..8cf4df1c1 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 16fb14922..fb190cf13 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 46487b5c1..10d763995 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 386c09a53..dd6cc7eac 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 adb446306..3bca69a26 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 ef32817f2..0148a7b06 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 3bbdac175..038e5f8fc 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 2e4a1b44d..a7b75774b 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs @@ -1375,6 +1375,280 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/subscriptions"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Subscriptions::SubscriptionCreateParams + { + AddAdjustments = + [ + new() + { + 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"), + }, + ], + AddPrices = + [ + new() + { + 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"), + }, + ], + AlignBillingWithSubscriptionStartDate = true, + AutoCollection = true, + AwsRegion = "aws_region", + BillingCycleAnchorConfiguration = new() + { + 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" } }, + 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() + { + 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", + }, + ], + ReplacePrices = + [ + new() + { + 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", + }, + ], + 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 diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsParamsTest.cs index 1437c75c3..12c3ea63a 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 742f4a13f..1a65dad7f 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 0ac8499f7..8fb8deac9 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 23af6df3d..e86627fe6 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 7af610102..5d9aeba09 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 73d6484b8..a213e423f 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 diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionRedeemCouponParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionRedeemCouponParamsTest.cs index bafb1f507..9742f2a5f 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 f1f3e6dbd..0807322db 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs @@ -783,6 +783,275 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Subscriptions::SubscriptionSchedulePlanChangeParams + { + SubscriptionID = "subscription_id", + ChangeOption = + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate, + AddAdjustments = + [ + new() + { + 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"), + }, + ], + AddPrices = + [ + new() + { + 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"), + }, + ], + AlignBillingWithPlanChangeDate = true, + AutoCollection = true, + BillingCycleAlignment = Subscriptions::BillingCycleAlignment.Unchanged, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, + }, + 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() + { + 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", + }, + ], + ReplacePrices = + [ + new() + { + 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", + }, + ], + TrialDurationDays = 0, + UsageCustomerIds = ["string"], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class SubscriptionSchedulePlanChangeParamsChangeOptionTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionTriggerPhaseParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionTriggerPhaseParamsTest.cs index 9267a7f81..6bfa2b26c 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 f7fe2dcdf..9ce3060d2 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 c8e5fa8a4..7da9e7a04 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 682224040..b8737d0ad 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 e06decc44..b51355302 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 663a07f57..db9d0febf 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 13aa6876d..177b748b0 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/Models/Alerts/AlertCreateForCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs index ff4f81781..6f6dcb70b 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,6 +185,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/AlertCreateForExternalCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs index 3e5cc7a05..69de9571f 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 14c41d7df..6fc4351eb 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 37a6fc2a6..b1148f385 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 530e5531b..50b9b152b 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 7bb864ca9..a6d9234b7 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 f966c61ba..a23480b0b 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 4ef7d2ad1..6e1e556c8 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 fa8856ae7..92b22906a 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))] diff --git a/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs b/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs index 2ed83f89a..640bb60cd 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 afc5ef444..51329b2a2 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 69dce5c83..ed52c032f 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 @@ -177,6 +181,8 @@ public bool? SetAsDefault public ExternalPlanIDCreatePlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDCreatePlanVersionParams( ExternalPlanIDCreatePlanVersionParams externalPlanIDCreatePlanVersionParams ) @@ -186,6 +192,7 @@ ExternalPlanIDCreatePlanVersionParams externalPlanIDCreatePlanVersionParams this._rawBodyData = new(externalPlanIDCreatePlanVersionParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalPlanIDCreatePlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -226,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( @@ -254,6 +285,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/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs index be2e0796f..dc5615885 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 48f536f06..8f7fe53ed 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/Coupons/CouponArchiveParams.cs b/src/Orb/Models/Coupons/CouponArchiveParams.cs index c952ddf51..a54235c43 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 c21d29d7a..dd7f76778 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 @@ -76,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, @@ -121,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") @@ -146,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))] diff --git a/src/Orb/Models/Coupons/CouponFetchParams.cs b/src/Orb/Models/Coupons/CouponFetchParams.cs index bd33502d5..f73172194 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 08ed5b233..f01453c5c 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 aa9f3573d..c527cbaa7 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 1969fb284..3a66a99a4 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 2754063d0..0eda4b9fc 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/CreditNotes/CreditNoteCreateParams.cs b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs index 043977ed7..74d00a8e4 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 @@ -125,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, @@ -170,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") @@ -195,6 +224,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/CreditNotes/CreditNoteFetchParams.cs b/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs index 3ff4c726a..8a2eeaa91 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 adff6e836..c53b8908c 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 ea000d1ad..2723f88e3 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,6 +170,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(TypeConverter))] diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs index fdc3ffad9..8538dac60 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 e9fd5b5cd..9393c43ea 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 e87ca9141..26d064cbe 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 07cec886d..5ccfb0775 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 343f39fd5..931ab8ec4 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/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index 98de12804..77de4183d 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 a667df269..d2a7a00b2 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))] diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs index e2c4466b5..8cec3cb17 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs @@ -77,8 +77,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 +210,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 +252,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 +299,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 6e6519a41..804b7d886 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs @@ -77,8 +77,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 +208,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 +250,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 +291,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 c260d51ff..0b32a35bb 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 3d1ff3c2d..8d310fcb0 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 67c920def..108aa80b2 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 581c2ebdd..6185f2930 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 4ea1cbcfc..63e1fec26 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 affa167c2..2976230c6 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 f59773040..65d75f56c 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; + } } /// diff --git a/src/Orb/Models/Customers/CustomerDeleteParams.cs b/src/Orb/Models/Customers/CustomerDeleteParams.cs index 9ea9ff627..005b9a5b6 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 567a20645..75aae9203 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 df3020ce6..341e92334 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 aa88c2b67..2e7ed9177 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 333276063..29778cac8 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 b48588ffb..d1630f40c 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 cdaab38bd..e27bc465f 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 084533d42..7533d7c28 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 727a7b7a3..2796c58a7 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 b0850dda4..6b10d0440 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 703425c82..c4227c5f7 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 14f6f05e1..4da736eab 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 abd46f11f..f3758a192 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 ff325e1fd..658a87ee3 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 e35f39d34..0273ed5fb 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 599437f17..da21ba31b 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/BackfillFetchParams.cs b/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs index da16f794e..d843457ed 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 bde773bd4..08526fa5b 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 5aaaacb07..5c37076bb 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 59cac2ffa..7354a41bc 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 dc9ebda8b..04b688bae 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 9dc0f9842..7d9a29f1a 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 05eb52a75..2a935ae4a 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/VolumeListParams.cs b/src/Orb/Models/Events/Volume/VolumeListParams.cs index eec55f973..8ab168de0 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 2604e2c94..c431ae916 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/Invoices/InvoiceCreateParams.cs b/src/Orb/Models/Invoices/InvoiceCreateParams.cs index c7f207722..e78d79d3d 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 @@ -202,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, @@ -247,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") @@ -272,6 +301,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/Invoices/InvoiceDeleteLineItemParams.cs b/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs index 526c14b14..3fc2cdbf1 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 563df22da..f9ad0653d 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 193ec1bf6..9ee83d4ab 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/InvoiceIssueParams.cs b/src/Orb/Models/Invoices/InvoiceIssueParams.cs index 4a7427ed2..f2944617a 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 440cce8cc..ca97359be 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 { @@ -252,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, @@ -288,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") @@ -304,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))] diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs index 72179935a..19b21e236 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 { @@ -269,8 +273,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 +312,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 +348,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(InvoiceListSummaryParamsDateTypeConverter))] diff --git a/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs b/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs index 0dd75ea13..616f3952a 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 58694581e..7026e0602 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 f5727977b..f7d4c2cbb 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 63a9c88ec..04e8c6a76 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 9ae2118ac..4b8cf9066 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 53f156719..d85df2e17 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 cd8f02363..119054224 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 5e12608f0..d08e7a2eb 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 f2e3552ae..68ef65fd2 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/MetricCreateParams.cs b/src/Orb/Models/Metrics/MetricCreateParams.cs index 2a7de8902..dfab3ac8d 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 51a02af22..09e5e1eb8 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 8feb4f9e1..73712145e 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 65848c97b..2aefc20eb 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 379ba1c88..3a0f2d760 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 f5e037605..82034fc86 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 3c14d6e9c..ead288e42 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 9968d05b6..e215d2f6e 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 03ee5e28c..f336a58f9 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/PlanCreateParams.cs b/src/Orb/Models/Plans/PlanCreateParams.cs index f4711b6aa..0aea030a0 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 @@ -191,11 +195,14 @@ public ApiEnum? Status 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, @@ -236,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") @@ -261,6 +290,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/Plans/PlanFetchParams.cs b/src/Orb/Models/Plans/PlanFetchParams.cs index 9fb892efc..fe3a4fd99 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 33edcf175..e59161cb2 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 876cd99a1..1f6d6f5aa 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/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs index db8f76d6f..8f318c9cf 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 dcbbe1f77..e553d5356 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 be327efcc..7fd431e4b 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; + } } /// diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs index 1b8aaa012..4222479d1 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))] diff --git a/src/Orb/Models/Prices/PriceEvaluateParams.cs b/src/Orb/Models/Prices/PriceEvaluateParams.cs index 84d73a41b..c3aa1822e 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 7e441a1e6..8f38fedea 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))] diff --git a/src/Orb/Models/Prices/PriceFetchParams.cs b/src/Orb/Models/Prices/PriceFetchParams.cs index 8b842a32f..e6bb466a8 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 8b29225f8..a37eb9489 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 4b06f3b18..8d4b9c21c 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 3c67a0f9c..04d739ee1 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 d13c4738a..dd84813b7 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 cac383741..d6730c4e6 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 @@ -84,8 +88,11 @@ public ApiEnum? Status public SubscriptionChangeListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeListParams(SubscriptionChangeListParams subscriptionChangeListParams) : base(subscriptionChangeListParams) { } +#pragma warning restore CS8618 public SubscriptionChangeListParams( IReadOnlyDictionary rawHeaderData, @@ -120,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( @@ -138,6 +165,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(StatusConverter))] diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs index 3f49c3275..63cc31aa3 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/SubscriptionCancelParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs index 7308e5a0d..080675a60 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 8fa21ef64..e5bec34b4 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))] diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs index 5dfc70260..1677747e7 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 3a5ac6bd6..8f7ea2acf 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 c273879a6..a5e13cd27 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 43e4d51f2..7fdeb1659 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 4c5026d58..66227c971 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 { @@ -163,8 +167,11 @@ public ApiEnum? Status public SubscriptionListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionListParams(SubscriptionListParams subscriptionListParams) : base(subscriptionListParams) { } +#pragma warning restore CS8618 public SubscriptionListParams( IReadOnlyDictionary rawHeaderData, @@ -199,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") @@ -215,6 +242,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(StatusConverter))] diff --git a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index ae080e213..6e31d5265 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))] diff --git a/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs b/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs index 392cb3fd7..3668dedc7 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 262e9fe60..7a5bd8667 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))] diff --git a/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs b/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs index 5477bafa1..9ae659d8d 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 0efc26fb4..6f3300f94 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 3e356fe6b..d68122526 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 7f50496aa..f18b7278a 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 afd9dab9f..beb63d107 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 cebb442bf..d40b97811 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 2868ee9c6..d455a5574 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 97a7b68b7..b4314ad11 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; + } } From 3bd6cd6413b421ff644eee7f195e6fe0af47c56c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 17 Jan 2026 00:25:06 +0000 Subject: [PATCH 05/39] feat(api): api update --- .stats.yml | 4 +- .../Beta/BetaCreatePlanVersionParamsTest.cs | 4758 +++------ ...ternalPlanIDCreatePlanVersionParamsTest.cs | 4758 +++------ .../Models/Plans/PlanCreateParamsTest.cs | 793 -- src/Orb.Tests/Models/PriceTest.cs | 4093 ++----- .../Models/Prices/PriceCreateParamsTest.cs | 772 -- .../Prices/PriceEvaluateMultipleParamsTest.cs | 791 -- .../PriceEvaluatePreviewEventsParamsTest.cs | 818 -- .../SubscriptionCreateParamsTest.cs | 7216 +++++-------- .../SubscriptionPriceIntervalsParamsTest.cs | 806 -- ...ubscriptionSchedulePlanChangeParamsTest.cs | 9443 +++++++---------- src/Orb/Core/ModelBase.cs | 27 - .../Beta/BetaCreatePlanVersionParams.cs | 8687 ++++++--------- .../ExternalPlanIDCreatePlanVersionParams.cs | 8687 ++++++--------- src/Orb/Models/Plans/Plan.cs | 8 +- src/Orb/Models/Plans/PlanCreateParams.cs | 820 -- src/Orb/Models/Price.cs | 5032 ++++----- src/Orb/Models/Prices/PriceCreateParams.cs | 803 -- .../Prices/PriceEvaluateMultipleParams.cs | 809 -- .../PriceEvaluatePreviewEventsParams.cs | 877 -- .../Subscriptions/SubscriptionCreateParams.cs | 9045 +++++++--------- .../SubscriptionPriceIntervalsParams.cs | 821 -- .../SubscriptionSchedulePlanChangeParams.cs | 6638 +++++------- 23 files changed, 25858 insertions(+), 50648 deletions(-) diff --git a/.stats.yml b/.stats.yml index 96825facf..666bff36b 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-c131de17773b450eb1ec03ca001f94d3777e35347234869a7efee083003e1513.yml +openapi_spec_hash: 5d2d4a3a9ada1c381efb318b6897994d config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs index f822bc692..7cad18738 100644 --- a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs @@ -3287,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() { @@ -4997,52 +4954,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - 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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - [Fact] public void NewPlanMinimumCompositeSerializationRoundtripWorks() { @@ -8402,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() @@ -8445,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() @@ -8462,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, @@ -8488,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); @@ -8516,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() @@ -8555,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); } @@ -8563,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() @@ -8602,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() @@ -8625,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, @@ -8651,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); @@ -8682,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() @@ -8726,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); @@ -8765,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(); @@ -8779,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, @@ -8832,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, @@ -8858,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 ); @@ -8887,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 ); @@ -8910,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 ); @@ -8924,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 ); @@ -8955,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"), @@ -9042,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( @@ -9062,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 ); @@ -9079,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( @@ -9094,7 +8947,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9103,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() @@ -9146,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() @@ -9159,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, @@ -9184,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); @@ -9213,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() @@ -9252,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); } @@ -9260,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() @@ -9299,18 +9175,23 @@ 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; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); - string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); - string expectedBillableMetricID = "billable_metric_id"; + 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() { @@ -9318,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, @@ -9343,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); @@ -9375,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() @@ -9419,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); @@ -9458,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(); @@ -9472,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, @@ -9525,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, @@ -9551,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 ); @@ -9580,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 ); @@ -9603,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 ); @@ -9617,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 ); @@ -9646,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"), @@ -9685,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( @@ -9705,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 ); @@ -9722,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( @@ -9737,7 +9721,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9746,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", - }; - - 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"; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - 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 ); @@ -9921,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(); } @@ -10095,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(); } @@ -10158,255 +9805,99 @@ 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 +public class RemovePriceTest : 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) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + 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 InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(model, deserialized); } - [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) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_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 - ); + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - Assert.Equal(value, deserialized); + model.Validate(); } -} -public class EventOutputConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id" }; - 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 EventOutputConfig - { - 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 EventOutputConfig - { - 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 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")); + 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(); } @@ -10414,402 +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( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - } - - [Fact] - public void Validation_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "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 - { - 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, - }; - - 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); - } - - [Fact] - public void SerializationRoundtrip_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 = 0, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -13292,57 +12502,14 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void NewPlanMinimumCompositeValidationWorks() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.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() - { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() - { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15031,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() @@ -16329,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() @@ -16344,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, @@ -16368,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); @@ -16398,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() @@ -16439,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 ); @@ -16450,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() @@ -16491,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() @@ -16512,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, @@ -16536,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); @@ -16569,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() @@ -16615,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); @@ -16656,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(); @@ -16672,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, @@ -16725,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 ); @@ -16860,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, @@ -16988,7 +15336,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17009,7 +15357,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17017,7 +15365,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17028,7 +15376,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17045,7 +15393,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17054,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() @@ -17103,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() @@ -17126,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, @@ -17151,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); @@ -17183,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() @@ -17228,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 ); @@ -17239,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() @@ -17284,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() @@ -17313,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, @@ -17338,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); @@ -17373,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() @@ -17423,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); @@ -17468,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(); @@ -17488,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, @@ -17545,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, @@ -17579,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(); } @@ -17599,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); @@ -17607,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); @@ -17632,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 ); @@ -17694,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, @@ -17755,7 +16106,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17776,7 +16127,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17784,7 +16135,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17795,7 +16146,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17812,7 +16163,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17821,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", @@ -17870,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"; @@ -17893,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, @@ -17919,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)); @@ -17950,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", @@ -17995,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 ); @@ -18006,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", @@ -18051,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"; @@ -18080,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, @@ -18106,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)); @@ -18140,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", @@ -18190,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", @@ -18235,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", @@ -18255,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", @@ -18314,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", @@ -18346,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(); } @@ -18366,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); @@ -18374,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); @@ -18399,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 ); @@ -18462,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, @@ -18522,7 +16873,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18543,7 +16894,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18551,7 +16902,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18562,7 +16913,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18579,7 +16930,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18588,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, @@ -18631,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; @@ -18649,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, @@ -18674,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); @@ -18703,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, @@ -18742,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 ); @@ -18753,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, @@ -18792,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; @@ -18816,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, @@ -18841,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); @@ -18873,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, @@ -18917,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", }; @@ -18956,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", }; @@ -18970,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, @@ -19023,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, @@ -19049,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); @@ -19100,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); } @@ -19152,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, @@ -19248,7 +17640,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19269,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); } @@ -19287,7 +17680,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19303,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/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs index 4754a003b..473bc2f81 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs @@ -3298,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() { @@ -5008,52 +4965,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - 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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - [Fact] public void NewPlanMinimumCompositeSerializationRoundtripWorks() { @@ -8413,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() @@ -8456,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() @@ -8473,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, @@ -8499,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); @@ -8527,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() @@ -8566,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); } @@ -8574,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() @@ -8613,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() @@ -8636,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, @@ -8662,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); @@ -8693,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() @@ -8737,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); @@ -8776,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(); @@ -8790,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, @@ -8843,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, @@ -8869,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 ); @@ -8898,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 ); @@ -8921,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 ); @@ -8935,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 ); @@ -8966,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"), @@ -9053,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( @@ -9073,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 ); @@ -9090,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( @@ -9105,7 +8958,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9114,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() @@ -9157,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() @@ -9170,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, @@ -9195,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); @@ -9224,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() @@ -9263,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); } @@ -9271,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() @@ -9310,18 +9186,23 @@ 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; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); - string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); - string expectedBillableMetricID = "billable_metric_id"; + 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() { @@ -9329,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, @@ -9354,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); @@ -9386,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() @@ -9430,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); @@ -9469,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(); @@ -9483,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, @@ -9536,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, @@ -9562,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 ); @@ -9591,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 ); @@ -9614,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 ); @@ -9628,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 ); @@ -9657,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"), @@ -9696,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( @@ -9716,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 ); @@ -9733,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( @@ -9748,7 +9732,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9757,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", - }; - - 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"; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - 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 ); @@ -9932,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(); } @@ -10106,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(); } @@ -10169,255 +9816,99 @@ 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 +public class RemovePriceTest : 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) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + 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 InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(model, deserialized); } - [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) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_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 - ); + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - Assert.Equal(value, deserialized); + model.Validate(); } -} -public class EventOutputConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id" }; - 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 EventOutputConfig - { - 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 EventOutputConfig - { - 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 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")); + 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(); } @@ -10425,402 +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( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - } - - [Fact] - public void Validation_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "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 - { - 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, - }; - - 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); - } - - [Fact] - public void SerializationRoundtrip_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 = 0, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -13303,57 +12513,14 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void NewPlanMinimumCompositeValidationWorks() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.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() - { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() - { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15042,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() @@ -16340,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() @@ -16355,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, @@ -16379,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); @@ -16409,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() @@ -16450,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 ); @@ -16461,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() @@ -16502,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() @@ -16523,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, @@ -16547,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); @@ -16580,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() @@ -16626,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); @@ -16667,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(); @@ -16683,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, @@ -16736,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 ); @@ -16871,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, @@ -16999,7 +15347,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17020,7 +15368,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17028,7 +15376,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17039,7 +15387,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17056,7 +15404,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17065,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() @@ -17114,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() @@ -17137,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, @@ -17162,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); @@ -17194,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() @@ -17239,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 ); @@ -17250,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() @@ -17295,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() @@ -17324,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, @@ -17349,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); @@ -17384,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() @@ -17434,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); @@ -17479,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(); @@ -17499,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, @@ -17556,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, @@ -17590,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(); } @@ -17610,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); @@ -17618,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); @@ -17643,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 ); @@ -17705,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, @@ -17766,7 +16117,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17787,7 +16138,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17795,7 +16146,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17806,7 +16157,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17823,7 +16174,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17832,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", @@ -17881,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"; @@ -17904,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, @@ -17930,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)); @@ -17961,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", @@ -18006,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 ); @@ -18017,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", @@ -18062,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"; @@ -18091,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, @@ -18117,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)); @@ -18151,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", @@ -18201,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", @@ -18246,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", @@ -18266,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", @@ -18325,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", @@ -18357,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(); } @@ -18377,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); @@ -18385,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); @@ -18410,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 ); @@ -18473,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, @@ -18533,7 +16884,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18554,7 +16905,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18562,7 +16913,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18573,7 +16924,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18590,7 +16941,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18599,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, @@ -18642,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; @@ -18660,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, @@ -18685,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); @@ -18714,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, @@ -18753,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 ); @@ -18764,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, @@ -18803,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; @@ -18827,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, @@ -18852,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); @@ -18884,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, @@ -18928,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", }; @@ -18967,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", }; @@ -18981,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, @@ -19034,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, @@ -19060,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); @@ -19111,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); } @@ -19163,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, @@ -19259,7 +17651,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19280,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); } @@ -19298,7 +17691,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19314,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/Plans/PlanCreateParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs index 55050d81f..a68a107fc 100644 --- a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs @@ -2866,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() { @@ -4660,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() { @@ -8077,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/PriceTest.cs b/src/Orb.Tests/Models/PriceTest.cs index f7a6bc8c1..27aeec1cc 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/PriceCreateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs index 7eddcfa33..a5714c815 100644 --- a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs @@ -1624,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() { @@ -3307,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() { @@ -5892,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 6ff36cf0c..a5fa9e783 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs @@ -2414,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() { @@ -4097,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() { @@ -6752,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/PriceEvaluatePreviewEventsParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs index 35c831070..261889130 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs @@ -2715,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() { @@ -4548,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() { @@ -7453,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/Subscriptions/SubscriptionCreateParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs index a7b75774b..d7fb74b59 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs @@ -4408,49 +4408,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - Subscriptions::Price value = new Subscriptions::Minimum() - { - 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_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 NewSubscriptionMinimumCompositeValidationWorks() { @@ -6227,55 +6184,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - Subscriptions::Price value = new Subscriptions::Minimum() - { - 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_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 NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { @@ -9687,17 +9595,17 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase +public class PercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::Percent { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::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() @@ -9730,16 +9638,12 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::MinimumCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::PercentCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + 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() @@ -9748,7 +9652,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9774,9 +9678,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); @@ -9802,12 +9706,12 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::Percent { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::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() @@ -9841,7 +9745,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9852,12 +9756,12 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::Percent { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::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() @@ -9891,22 +9795,18 @@ 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::PercentCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + 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() @@ -9915,7 +9815,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9941,9 +9841,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); @@ -9972,12 +9872,12 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::Percent { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::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() @@ -10016,12 +9916,12 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::Percent { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -10055,12 +9955,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::Percent { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -10069,12 +9969,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::Percent { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10122,12 +10022,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::Percent { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10148,26 +10048,26 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class MinimumCadenceTest : TestBase +public class PercentCadenceTest : 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::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) { // 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 ); @@ -10177,20 +10077,20 @@ public void InvalidEnumValidationThrows_Works() } [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::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) { // 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); @@ -10199,48 +10099,38 @@ public void SerializationRoundtrip_Works(Subscriptions::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< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class MinimumConfigTest : TestBase +public class PercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = new Subscriptions::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 Subscriptions::MinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = new Subscriptions::PercentConfig { Percent = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10251,91 +10141,35 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::MinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = new Subscriptions::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 Subscriptions::MinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::MinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new Subscriptions::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 Subscriptions::MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + var model = new Subscriptions::PercentConfig { Percent = 0 }; model.Validate(); } } -public class MinimumConversionRateConfigTest : TestBase +public class PercentConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -10346,7 +10180,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -10366,13 +10200,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() { 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 ); @@ -10383,7 +10217,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -10398,7 +10232,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10407,17 +10241,22 @@ public void TieredSerializationRoundtripWorks() } } -public class PercentTest : TestBase +public class EventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::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() @@ -10450,12 +10289,17 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::PercentCadence.Annual; + 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("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; - Subscriptions::PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10464,7 +10308,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10489,10 +10333,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); @@ -10518,12 +10362,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::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() @@ -10557,7 +10406,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10568,12 +10417,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::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() @@ -10607,18 +10461,23 @@ 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::EventOutputCadence.Annual; + Subscriptions::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"; - Subscriptions::PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10627,7 +10486,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10652,10 +10511,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); @@ -10684,12 +10543,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::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() @@ -10728,12 +10592,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::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); @@ -10767,12 +10636,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; model.Validate(); @@ -10781,12 +10655,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::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, @@ -10834,12 +10713,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::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, @@ -10860,26 +10744,26 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class PercentCadenceTest : TestBase +public class EventOutputCadenceTest : 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::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; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -10889,20 +10773,20 @@ public void InvalidEnumValidationThrows_Works() } [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::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; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -10911,38 +10795,52 @@ public void SerializationRoundtrip_Works(Subscriptions::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< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PercentConfigTest : TestBase +public class EventOutputConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::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 Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::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 ); @@ -10953,513 +10851,370 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::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 Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; model.Validate(); } -} -public class PercentConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() + 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 { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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 TieredValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() + var model = new Subscriptions::EventOutputConfig { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, }; - value.Validate(); + + model.Validate(); } +} +public class EventOutputConversionRateConfigTest : TestBase +{ [Fact] - public void UnitSerializationRoundtripWorks() + public void UnitValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() + 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); + value.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void TieredValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() + Subscriptions::EventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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); } -} -public class EventOutputTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void TieredSerializationRoundtripWorks() { - 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", - BillableMetricID = "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 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() + Subscriptions::EventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; - 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"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - 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, deserialized); + } +} - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); +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 SerializationRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { - 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", - BillableMetricID = "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, + var value = JsonSerializer.Deserialize>( + 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::ExternalMarketplace.Google)] + [InlineData(Subscriptions::ExternalMarketplace.Aws)] + [InlineData(Subscriptions::ExternalMarketplace.Azure)] + public void SerializationRoundtrip_Works(Subscriptions::ExternalMarketplace rawValue) { - 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", - BillableMetricID = "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", - }; + // 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( + 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", - }; - 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 expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + 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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::RemovePrice { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; + string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedPriceID, model.PriceID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::RemovePrice { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; - 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 + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + 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(model, deserialized); } [Fact] - public void Validation_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::RemovePrice { - 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", + PriceID = "h74gfhdjvn7ujokd", }; - model.Validate(); + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + public void Validation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::RemovePrice { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; - 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")); + 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.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.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - 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", - }; + var model = new Subscriptions::RemovePrice { }; model.Validate(); } @@ -11467,1175 +11222,887 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - 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", - - 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, - }; + var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = 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.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - 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", - - 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, - }; + var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; model.Validate(); } } -public class EventOutputCadenceTest : TestBase +public class ReplaceAdjustmentTest : 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) + [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::ReplaceAdjustment + { + 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::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, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + var model = new Subscriptions::ReplaceAdjustment + { + 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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(model, deserialized); } - [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) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // 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 EventOutputConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::EventOutputConfig - { - 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::EventOutputConfig - { - 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::EventOutputConfig + var model = new Subscriptions::ReplaceAdjustment { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + 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, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); } [Fact] public void Validation_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::ReplaceAdjustment { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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(); } +} +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ [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() + public void NewPercentageDiscountValidationWorks() { - var model = new Subscriptions::EventOutputConfig + Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewUsageDiscountValidationWorks() { - var model = new Subscriptions::EventOutputConfig + Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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, }; - - model.Validate(); + value.Validate(); } -} -public class EventOutputConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewAmountDiscountValidationWorks() { - Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() + Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() { - 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", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; value.Validate(); } [Fact] - public void TieredValidationWorks() + public void NewMinimumValidationWorks() { - Subscriptions::EventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + 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(); } [Fact] - public void UnitSerializationRoundtripWorks() + public void NewMaximumValidationWorks() { - Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() { - 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", + 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); + value.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() { - Subscriptions::EventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + 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, - 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) + [Fact] + public void NewUsageDiscountSerializationRoundtripWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + 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( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void NewAmountDiscountSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + 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, + }; + 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::ExternalMarketplace.Google)] - [InlineData(Subscriptions::ExternalMarketplace.Aws)] - [InlineData(Subscriptions::ExternalMarketplace.Azure)] - public void SerializationRoundtrip_Works(Subscriptions::ExternalMarketplace rawValue) + [Fact] + public void NewMinimumSerializationRoundtripWorks() { - // 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::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, + }; + 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 NewMaximumSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + 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, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, 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 +public class ReplacePriceTest : 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 -{ - [Fact] - public void FieldRoundtrip_Works() - { - 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 SerializationRoundtrip_Works() - { - 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 FieldRoundtripThroughSerialization_Works() - { - 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 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 }; - - model.Validate(); - } -} - -public class ReplaceAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::ReplacePrice { - Adjustment = new NewPercentageDiscount() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, Filters = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }, - 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 = + Discounts = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::ReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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", }, - ReplacesAdjustmentID = "replaces_adjustment_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::ReplaceAdjustment + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() { - Adjustment = new NewPercentageDiscount() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = 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 = CustomExpirationDurationUnit.Day, }, - 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", + ExpiresAtEndOfCadence = true, Filters = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + 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() + { + 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(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + 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 Validation_Works() + public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::ReplacePrice { - Adjustment = new NewPercentageDiscount() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, Filters = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }, - 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 = + Discounts = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewUsageDiscountValidationWorks() - { - 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() + 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() { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewAmountDiscountValidationWorks() - { - 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() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewMinimumValidationWorks() - { - 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() + Currency = "currency", + DimensionalPriceConfiguration = new() { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - ], - 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() + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + PriceID = "h74gfhdjvn7ujokd", }; - value.Validate(); - } - [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() - { - 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, + 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() + var model = new Subscriptions::ReplacePrice { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + 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() { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, + 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", }; - 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 NewAmountDiscountSerializationRoundtripWorks() - { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, 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::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, - }; - 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() - { - 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 ReplacePriceTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::ReplacePrice - { - 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", - }; - - 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, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], @@ -12697,24 +12164,24 @@ public void FieldRoundtrip_Works() }; string expectedPriceID = "h74gfhdjvn7ujokd"; - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.NotNull(model.Discounts); - Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); + 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], model.Discounts[i]); + Assert.Equal(expectedDiscounts[i], deserialized.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); + 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 SerializationRoundtrip_Works() + public void Validation_Works() { var model = new Subscriptions::ReplacePrice { @@ -12797,65 +12264,260 @@ public void SerializationRoundtrip_Works() PriceID = "h74gfhdjvn7ujokd", }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + model.Validate(); + } - Assert.Equal(model, deserialized); + [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 FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new Subscriptions::ReplacePrice { ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + + 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::ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MinimumAmount = null, + Price = null, + PriceID = null, + }; + + model.Validate(); + } +} + +public class ReplacePricePriceTest : TestBase +{ + [Fact] + public void NewSubscriptionUnitValidationWorks() + { + 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", + }; + 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() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + 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", }, - 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, + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionBulkValidationWorks() + { + Subscriptions::ReplacePricePrice 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::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", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12886,63 +12548,123 @@ public void FieldRoundtripThroughSerialization_Works() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + }; + value.Validate(); + } - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() + [Fact] + public void NewSubscriptionPackageValidationWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() { - 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"], - }, - ], + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + 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", }; - List expectedDiscounts = - [ - new() + value.Validate(); + } + + [Fact] + public void NewSubscriptionMatrixValidationWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ]; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 2; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - Subscriptions::ReplacePricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + 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::ReplacePricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + { + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -12974,74 +12696,28 @@ public void FieldRoundtripThroughSerialization_Works() 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); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionTieredPackageValidationWorks() { - var model = new Subscriptions::ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackagePrice() { - 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"], - }, - ], + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], }, - ], - 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() @@ -13072,263 +12748,93 @@ public void Validation_Works() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - 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 OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - - model.Validate(); + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionTieredWithMinimumValidationWorks() { - var model = new Subscriptions::ReplacePrice - { - 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::ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceTest : TestBase -{ - [Fact] - public void NewSubscriptionUnitValidationWorks() - { - 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", - }; - 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(); - } - - [Fact] - public void NewSubscriptionBulkValidationWorks() - { - Subscriptions::ReplacePricePrice 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() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + 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 BulkWithFiltersValidationWorks() + public void NewSubscriptionGroupedTieredValidationWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceBulkWithFilters() + 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::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13365,117 +12871,34 @@ public void BulkWithFiltersValidationWorks() } [Fact] - public void NewSubscriptionPackageValidationWorks() - { - Subscriptions::ReplacePricePrice 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::ReplacePricePrice 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() + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, Name = "Annual fee", - ThresholdTotalAmountConfig = new() + TieredPackageWithMinimumConfig = new() { - ConsumptionTable = + PackageSize = 0, + Tiers = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, ], - Prorate = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13512,23 +12935,21 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() } [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", - TieredPackageConfig = new() + PackageWithAllocationConfig = new() { + Allocation = "allocation", + PackageAmount = "package_amount", 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, @@ -13565,36 +12986,17 @@ public void NewSubscriptionTieredPackageValidationWorks() } [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, 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, - }, + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13630,23 +13032,25 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() { - GroupingKey = "x", - Tiers = + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13683,35 +13087,17 @@ public void NewSubscriptionGroupedTieredValidationWorks() } [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void TieredWithProrationValidationWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::ReplacePricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.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", - }, - ], - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13747,22 +13133,17 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() } [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() + public void NewSubscriptionUnitWithProrationValidationWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13798,17 +13179,22 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() } [Fact] - public void NewSubscriptionUnitWithPercentValidationWorks() + public void NewSubscriptionGroupedAllocationValidationWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13844,208 +13230,10 @@ public void NewSubscriptionUnitWithPercentValidationWorks() } [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() + public void NewSubscriptionBulkWithProrationValidationWorks() { 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(); - } - - [Fact] - public void TieredWithProrationValidationWorks() - { - 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(); - } - - [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() - { - 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", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() - { - 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", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { BulkWithProrationConfig = new( [ @@ -14662,49 +13850,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - 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", - }; - value.Validate(); - } - [Fact] public void NewSubscriptionMinimumCompositeValidationWorks() { @@ -16478,1260 +15623,215 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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); - } - - [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() - { - 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); - } - - [Fact] - public void PercentSerializationRoundtripWorks() - { - 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_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 EventOutputSerializationRoundtripWorks() - { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceEventOutput() - { - 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", - }; - 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 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", - }; - - 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); - } - - [Fact] - public void SerializationRoundtrip_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 = "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, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_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 = "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); - - 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 - ); - 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::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", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_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", - }; - - 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::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", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_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, - }; - - 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::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::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 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 SerializationRoundtrip_Works() - { - var model = new Subscriptions::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 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"; - - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::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 Subscriptions::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 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"; - - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - 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 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(); - } - - [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 - ) - { - // 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); + 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() @@ -17764,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() @@ -17781,7 +15887,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17805,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); @@ -17835,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() @@ -17877,7 +15989,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17888,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() @@ -17930,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() @@ -17953,7 +16077,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17977,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); @@ -18010,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() @@ -18056,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); @@ -18097,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(); @@ -18113,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, @@ -18166,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 ); @@ -18307,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, @@ -18439,7 +16749,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18460,7 +16770,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18468,7 +16778,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18479,7 +16789,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18496,7 +16806,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18505,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() @@ -18556,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() @@ -18580,7 +16877,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18605,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); @@ -18637,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() @@ -18683,7 +16973,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18694,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() @@ -18740,7 +17026,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18748,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() @@ -18772,7 +17049,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18797,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); @@ -18832,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() @@ -18882,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); @@ -18927,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(); @@ -18947,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, @@ -19006,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, @@ -19038,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(); } @@ -19061,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); @@ -19069,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); @@ -19095,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 ); @@ -19158,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, @@ -19218,7 +17535,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19239,7 +17556,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19247,7 +17564,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19258,7 +17575,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19275,7 +17592,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19284,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", @@ -19335,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"; @@ -19359,7 +17676,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19385,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)); @@ -19416,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", @@ -19462,7 +17779,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19473,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", @@ -19519,7 +17836,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19527,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"; @@ -19551,7 +17868,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19577,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)); @@ -19611,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", @@ -19661,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", @@ -19706,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", @@ -19726,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", @@ -19785,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", @@ -19817,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(); } @@ -19840,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); @@ -19848,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); @@ -19874,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 ); @@ -19937,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, @@ -19997,7 +18314,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20018,7 +18335,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20026,7 +18343,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20037,7 +18354,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20054,7 +18371,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20063,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, @@ -20106,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; @@ -20124,7 +18455,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20149,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); @@ -20178,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, @@ -20217,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); } @@ -20228,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, @@ -20267,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; @@ -20291,7 +18647,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20316,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); @@ -20348,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, @@ -20392,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", }; @@ -20431,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", }; @@ -20445,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, @@ -20498,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, @@ -20524,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(); } @@ -20544,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); @@ -20552,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); @@ -20577,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 ); @@ -20628,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, @@ -20731,7 +19093,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20752,7 +19114,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20760,7 +19122,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20771,7 +19133,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20788,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/SubscriptionPriceIntervalsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs index a213e423f..d66ad3bdd 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs @@ -3404,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() { @@ -5166,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() { @@ -7869,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/SubscriptionSchedulePlanChangeParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs index 0807322db..451cef5eb 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs @@ -3934,51 +3934,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - 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() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - [Fact] public void NewSubscriptionMinimumCompositeValidationWorks() { @@ -5826,58 +5781,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - 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() - { - 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 NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { @@ -9661,18 +9564,18 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.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() @@ -9707,14 +9610,14 @@ public void FieldRoundtrip_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + 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() @@ -9723,7 +9626,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9749,9 +9652,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); @@ -9777,13 +9680,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.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() @@ -9818,7 +9721,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9829,13 +9732,13 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.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() @@ -9870,7 +9773,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9878,14 +9781,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + 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() @@ -9894,7 +9797,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9920,9 +9823,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); @@ -9951,13 +9854,13 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.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() @@ -9996,13 +9899,13 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -10036,13 +9939,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -10051,13 +9954,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10105,13 +10008,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10132,35 +10035,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; value.Validate(); } @@ -10171,7 +10074,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -10181,38 +10084,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -10225,14 +10128,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -10240,38 +10143,34 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Percent = 0, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10283,104 +10182,44 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Percent = 0, }; 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; + 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 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::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + Percent = 0, }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10392,7 +10231,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10413,7 +10252,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10421,7 +10260,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10432,7 +10271,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10449,7 +10288,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10458,18 +10297,23 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.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() @@ -10504,14 +10348,19 @@ public void FieldRoundtrip_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig 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"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = - new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10520,7 +10369,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10545,10 +10394,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); @@ -10574,13 +10423,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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() @@ -10615,7 +10469,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10626,13 +10480,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.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() @@ -10667,7 +10526,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10675,14 +10534,19 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig 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"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = - new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10691,7 +10555,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10716,10 +10580,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); @@ -10748,13 +10612,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.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() @@ -10793,13 +10662,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.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); @@ -10833,13 +10707,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; model.Validate(); @@ -10848,13 +10727,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.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, @@ -10902,13 +10786,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.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, @@ -10929,35 +10818,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > value = rawValue; value.Validate(); } @@ -10968,7 +10857,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -10978,38 +10867,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(json, ModelBase.SerializerOptions); @@ -11022,14 +10911,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(json, ModelBase.SerializerOptions); @@ -11037,34 +10926,43 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - Percent = 0, + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - Percent = 0, + 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 ); @@ -11076,44 +10974,112 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - Percent = 0, + 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); - 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - Percent = 0, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11125,7 +11091,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -11146,7 +11112,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11154,7 +11120,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11165,7 +11131,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -11182,7 +11148,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11191,179 +11157,88 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase +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 FieldRoundtrip_Works() + public void InvalidEnumValidationThrows_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", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - 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() + 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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AdjustmentID = "h74gfhdjvn7ujokd", }; - 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 = "h74gfhdjvn7ujokd"; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedAdjustmentID, model.AdjustmentID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - 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", + AdjustmentID = "h74gfhdjvn7ujokd", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11374,180 +11249,104 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - 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", + AdjustmentID = "h74gfhdjvn7ujokd", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - 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() + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AdjustmentID = "h74gfhdjvn7ujokd", }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + + model.Validate(); + } +} + +public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; + string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedPriceID, model.PriceID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; - 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) + 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 { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - 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", + PriceID = "h74gfhdjvn7ujokd", }; model.Validate(); @@ -11556,64 +11355,18 @@ public void Validation_Works() [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", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - 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.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_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", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; model.Validate(); } @@ -11621,400 +11374,420 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + ExternalPriceID = null, + PriceID = 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")); - 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.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - 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, + PriceID = null, }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : 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 - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > value = rawValue; - value.Validate(); - } - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [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 - ) + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > value = rawValue; + 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 json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > - >(json, ModelBase.SerializerOptions); + 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(value, deserialized); + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void SerializationRoundtrip_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); + 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", + }; - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - 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", - }; + 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + 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(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); } [Fact] public void Validation_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + 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(); } +} +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewPercentageDiscountValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() { - UnitRatingKey = "x", + 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.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewUsageDiscountValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() { - UnitRatingKey = "x", + 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, }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewAmountDiscountValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewAmountDiscount() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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, }; - - Assert.Null(model.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewMinimumValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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, }; - - model.Validate(); + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewMaximumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() { - 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", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; value.Validate(); } [Fact] - public void TieredValidationWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void NewUsageDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() { - 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", + 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -12023,2218 +11796,161 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewAmountDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewAmountDiscount() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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( + 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 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) + public void NewMinimumSerializationRoundtripWorks() { - // 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::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment 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 InvalidEnumSerializationRoundtrip_Works() + public void NewMaximumSerializationRoundtripWorks() { - 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::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 + ); Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : 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::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - 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::SubscriptionSchedulePlanChangeParamsRemoveAdjustment - { - 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::SubscriptionSchedulePlanChangeParamsRemoveAdjustment - { - 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", - }; - - 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::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - 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")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - 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::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = null, - PriceID = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : 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() - { - 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, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); - } - - [Fact] - public void SerializationRoundtrip_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", - }; - - 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::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() - { - 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(); - } -} - -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(); - } - - [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, - }; - value.Validate(); - } - - [Fact] - public void NewAmountDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment 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::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment 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::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, - }; - value.Validate(); - } - - [Fact] - 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::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, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment 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::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment 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::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 - ); - - Assert.Equal(value, deserialized); - } -} - -public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase -{ - [Fact] - public void FieldRoundtrip_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", - }; - - 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(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 SerializationRoundtrip_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", - }; - - 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::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", - }; - - 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() - { - 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(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 - { - 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", - }; - - model.Validate(); - } - - [Fact] - 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::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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - 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", - BillableMetricID = "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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice 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::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() - { - 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() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = 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 NewSubscriptionUnitWithProrationValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14265,78 +11981,56 @@ public void NewSubscriptionUnitWithProrationValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + }; - [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = 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() - { - 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 = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + 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() @@ -14368,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() @@ -14484,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() @@ -14535,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() @@ -14594,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() @@ -14648,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() @@ -14708,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, @@ -14770,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() @@ -14835,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, @@ -14893,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() @@ -14944,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, @@ -14989,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() @@ -15039,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() @@ -15084,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() @@ -15134,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() @@ -15175,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, @@ -15239,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() @@ -15291,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() @@ -15351,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() @@ -15403,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() @@ -15463,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() @@ -15524,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() @@ -15584,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() @@ -15656,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, @@ -15716,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() @@ -15787,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() @@ -15845,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() @@ -15898,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, @@ -15958,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() @@ -16014,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() @@ -16067,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() @@ -16125,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, @@ -16183,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, @@ -16242,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, @@ -16314,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() @@ -16372,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, @@ -16437,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() @@ -16510,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() @@ -16572,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() @@ -16641,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() @@ -16713,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() @@ -16778,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, @@ -16836,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() @@ -16888,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() @@ -16945,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() @@ -16997,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, @@ -17052,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() @@ -17106,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() @@ -17234,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() @@ -17295,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, @@ -17434,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 ); @@ -18115,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 ); @@ -18143,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() @@ -18190,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() @@ -18208,7 +16142,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18232,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); @@ -18263,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() @@ -18306,7 +16246,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18318,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() @@ -18361,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() @@ -18385,7 +16339,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18409,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); @@ -18443,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() @@ -18491,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); @@ -18534,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(); @@ -18552,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, @@ -18609,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, @@ -18638,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 ); @@ -18794,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 ); @@ -18876,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, @@ -18929,7 +17086,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18950,7 +17107,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18958,7 +17115,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18969,7 +17126,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18986,7 +17143,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18995,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() @@ -19049,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() @@ -19073,7 +17217,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19098,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); @@ -19131,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() @@ -19178,7 +17315,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19190,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() @@ -19237,7 +17370,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19245,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() @@ -19269,7 +17394,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19294,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); @@ -19330,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() @@ -19382,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); @@ -19429,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(); @@ -19451,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, @@ -19512,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, @@ -19545,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(); } @@ -19585,7 +17687,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -19595,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); @@ -19639,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); @@ -19654,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 ); @@ -19706,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, @@ -19767,7 +17938,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19788,7 +17959,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19796,7 +17967,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19807,7 +17978,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19824,7 +17995,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19833,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", @@ -19887,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"; @@ -19911,7 +18082,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19937,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)); @@ -19969,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", @@ -20016,7 +18187,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20028,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", @@ -20075,7 +18246,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20083,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"; @@ -20107,7 +18278,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20133,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)); @@ -20168,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", @@ -20220,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", @@ -20267,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", @@ -20289,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", @@ -20350,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", @@ -20383,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(); } @@ -20423,7 +18594,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20433,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); @@ -20477,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); @@ -20492,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 ); @@ -20544,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, @@ -20605,7 +18776,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20626,7 +18797,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20634,7 +18805,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20645,7 +18816,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20662,7 +18833,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20671,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; @@ -20733,7 +18920,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20758,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); @@ -20787,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 ); @@ -20839,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 ); @@ -20888,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; @@ -20904,7 +19116,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20929,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); @@ -20961,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(); } @@ -21006,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")); @@ -21046,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(); } @@ -21061,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")); @@ -21115,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(); } @@ -21181,7 +19432,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -21191,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); @@ -21235,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); @@ -21250,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 ); @@ -21294,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, @@ -21403,7 +19614,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21424,7 +19635,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -21432,7 +19643,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -21443,7 +19654,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21460,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/Core/ModelBase.cs b/src/Orb/Core/ModelBase.cs index 165003cf9..d74ae4e8a 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(), @@ -599,7 +590,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -620,13 +610,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 +629,6 @@ protected ModelBase(ModelBase modelBase) string, Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence - >(), new ApiEnumConverter< string, Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence @@ -825,7 +809,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -842,7 +825,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -859,7 +841,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::PriceModelCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -883,10 +864,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence - >(), new ApiEnumConverter< string, Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence @@ -912,10 +889,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence - >(), new ApiEnumConverter< string, Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence diff --git a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs index 92b22906a..8f63e6672 100644 --- a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs @@ -977,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 @@ -1018,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 @@ -1059,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 @@ -1100,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 @@ -1141,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 @@ -1182,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 @@ -1223,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 @@ -1264,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 @@ -1305,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 @@ -1346,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 @@ -1387,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 @@ -1428,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 @@ -1469,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 @@ -1645,12 +1632,6 @@ public Price(CumulativeGroupedAllocation value, JsonElement? element = null) this._element = element; } - public Price(Minimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -2304,27 +2285,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 `Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) - { - value = this.Value as Minimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -2432,7 +2392,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -2469,7 +2428,6 @@ public void Switch( System::Action newPlanScalableMatrixWithTieredPricing, System::Action newPlanCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newPlanMinimumComposite, System::Action percent, System::Action eventOutput @@ -2561,9 +2519,6 @@ public void Switch( case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case Minimum value: - minimum(value); - break; case NewPlanMinimumCompositePrice value: newPlanMinimumComposite(value); break; @@ -2621,7 +2576,6 @@ public void Switch( /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -2664,7 +2618,6 @@ public T Match( > newPlanScalableMatrixWithTieredPricing, System::Func newPlanCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newPlanMinimumComposite, System::Func percent, System::Func eventOutput @@ -2705,7 +2658,6 @@ public T Match( newPlanScalableMatrixWithTieredPricing(value), NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - Minimum value => minimum(value), NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), Percent value => percent(value), EventOutput value => eventOutput(value), @@ -2773,8 +2725,6 @@ public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPric public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator Price(Minimum value) => new(value); - public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); public static implicit operator Price(Percent value) => new(value); @@ -2828,7 +2778,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() @@ -3495,25 +3444,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 @@ -6896,18 +6826,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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); } } @@ -6926,42 +6856,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required 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); } } /// @@ -7023,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" ); } @@ -7159,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(); @@ -7180,48 +7110,48 @@ public override void Validate() _ = this.ReferenceID; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(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 Minimum FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => - 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, @@ -7231,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 @@ -7241,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 ) { @@ -7261,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)) ), @@ -7277,93 +7207,71 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter(typeof(JsonModelConverter))] -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(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 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 MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - 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; @@ -7380,7 +7288,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7389,7 +7297,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7398,7 +7306,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -7480,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" ); } } @@ -7516,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); @@ -7544,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); } @@ -7564,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 @@ -7631,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 ) { @@ -7646,22 +7554,35 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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>("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. /// @@ -7701,19 +7622,6 @@ 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. /// @@ -7773,12 +7681,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PercentConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7908,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(); @@ -7930,48 +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(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 Percent FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => - Percent.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -7981,9 +7894,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override PercentCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7991,19 +7904,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PercentCadence.Annual, - "semi_annual" => PercentCadence.SemiAnnual, - "monthly" => PercentCadence.Monthly, - "quarterly" => PercentCadence.Quarterly, - "one_time" => PercentCadence.OneTime, - "custom" => PercentCadence.Custom, - _ => (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, - PercentCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -8011,12 +7924,12 @@ JsonSerializerOptions options writer, value switch { - PercentCadence.Annual => "annual", - PercentCadence.SemiAnnual => "semi_annual", - PercentCadence.Monthly => "monthly", - PercentCadence.Quarterly => "quarterly", - PercentCadence.OneTime => "one_time", - 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)) ), @@ -8027,71 +7940,104 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for event_output pricing /// -[JsonConverter(typeof(JsonModelConverter))] -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(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 PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static EventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public PercentConfig(double percent) + public EventOutputConfig(string unitRatingKey) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class PercentConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - PercentConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8108,7 +8054,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8117,7 +8063,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8126,7 +8072,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -8208,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" ); } } @@ -8244,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 PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8272,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(PercentConversionRateConfig? other) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -8292,9 +8238,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter : JsonConverter +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - public override PercentConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8359,14 +8306,14 @@ JsonSerializerOptions options } default: { - return new PercentConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PercentConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -8374,568 +8321,428 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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>("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 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); } + } + + /// + public override void Validate() + { + _ = this.AdjustmentID; + _ = this.PlanPhaseOrder; + } + + public RemoveAdjustment() { } + + public RemoveAdjustment(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 RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() + { + this.AdjustmentID = adjustmentID; } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// The id of the item the price will be associated with. + /// The id of the price to remove from the plan. /// - public required string ItemID + public required string PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass("price_id"); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("price_id", value); } } /// - /// The pricing model type + /// The phase to remove this price from. /// - public JsonElement ModelType + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("model_type", value); } + 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 name of the price. + /// The definition of a new adjustment to create and add to the plan. /// - public required string Name + public required ReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("adjustment"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// The id of the adjustment on the plan to replace in the plan. /// - public string? BillableMetricID + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("billable_metric_id", value); } + init { this._rawData.Set("replaces_adjustment_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. + /// The phase to replace this adjustment from. /// - public bool? BilledInAdvance + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("billed_in_advance", value); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; + _ = this.PlanPhaseOrder; } - /// - /// 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); } - } + public ReplaceAdjustment() { } - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public EventOutputConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency + public ReplaceAdjustment(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] + ReplaceAdjustment(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 ReplaceAdjustment 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 - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } +class ReplaceAdjustmentFromRaw : IFromRawJson +{ + /// + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); +} - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey +/// +/// 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 { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - 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 + public string? Currency { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" + 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("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 + public bool? IsInvoiceLevel { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel ); } } - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID + public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { - 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.Value = value; + this._element = element; } - public EventOutput() + public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.Value = value; + this._element = element; } - public EventOutput(EventOutput eventOutput) - : base(eventOutput) { } - - public EventOutput(IReadOnlyDictionary rawData) + public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) + public ReplaceAdjustmentAdjustment(JsonElement element) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this._element = element; } -} -class EventOutputFromRaw : IFromRawJson -{ - /// - public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutput.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(EventOutputCadenceConverter))] -public enum EventOutputCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class EventOutputCadenceConverter : JsonConverter -{ - public override EventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "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, - EventOutputCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); - } -} - -/// -/// Configuration for event_output pricing -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutputConfig : JsonModel -{ /// - /// The key in the event data to extract the unit rate from. + /// 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 required string UnitRatingKey + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); - } - init { this._rawData.Set("unit_rating_key", value); } + value = this.Value as NewPercentageDiscount; + return value != null; } /// - /// 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. + /// 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 string? DefaultUnitRate + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); - } - init { this._rawData.Set("default_unit_rate", value); } + value = this.Value as NewUsageDiscount; + return value != null; } /// - /// An optional key in the event data to group by (e.g., event ID). All events - /// will also be grouped by their unit rate. + /// 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 string? GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } - } - - /// - public override void Validate() - { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; - } - - public EventOutputConfig() { } - - public EventOutputConfig(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 EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() - { - this.UnitRatingKey = unitRatingKey; - } -} - -class EventOutputConfigFromRaw : IFromRawJson -{ - /// - public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(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 - ) - { - this.Value = value; - this._element = element; - } - - public EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public EventOutputConversionRateConfig(JsonElement element) + 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; } @@ -8953,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 + 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" ); } } @@ -8994,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 EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator 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 @@ -9038,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(EventOutputConversionRateConfig? other) + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9058,33 +8900,32 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override 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 ); @@ -9102,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 ); @@ -9124,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 EventOutputConversionRateConfig(element); + return new ReplaceAdjustmentAdjustment(element); } } } public override void Write( Utf8JsonWriter writer, - EventOutputConversionRateConfig value, + ReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { @@ -9141,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 { @@ -9170,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() + public string Name { - this.PriceID = priceID; + 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, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } -} - -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? BillableMetricID { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + 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("adjustment", value); } } - /// - /// The id of the adjustment on the plan to replace in the plan. - /// - public required string ReplacesAdjustmentID + public bool? BilledInAdvance { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + 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("replaces_adjustment_id", value); } } - /// - /// The phase to replace this adjustment from. - /// - public long? PlanPhaseOrder + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + 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 + ); } - init { this._rawData.Set("plan_phase_order", value); } } - /// - public override void Validate() - { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; - } - - 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 ); } } @@ -9403,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) + 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(NewMinimum 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(NewMaximum value, JsonElement? element = null) + public string? InvoiceGroupingKey { - this.Value = value; - this._element = element; + 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 ReplaceAdjustmentAdjustment(JsonElement element) + 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, + 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, + 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; } - /// - /// 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 ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) { - value = this.Value as NewPercentageDiscount; - 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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) { - value = this.Value as NewUsageDiscount; - 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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public ReplacePricePrice(ReplacePricePriceBulkWithFilters 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(NewPlanPackagePrice 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(NewPlanMatrixPrice 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(NewPlanThresholdTotalAmountPrice 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(NewPlanTieredPackagePrice value, JsonElement? element = null) + { + 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 ) { - 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(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => - new(value); + public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => - new(value); + public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); + public ReplacePricePrice(NewPlanUnitWithProrationPrice 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(NewPlanGroupedAllocationPrice 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(NewPlanBulkWithProrationPrice 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( + NewPlanGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + public ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice 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( + ReplacePricePriceGroupedWithMinMaxThresholds 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(NewPlanMatrixWithDisplayNamePrice 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(NewPlanGroupedTieredPackagePrice 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 ReplaceAdjustmentAdjustment(element); - } - } + public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice 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( + NewPlanScalableMatrixWithTieredPricingPrice 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(NewPlanCumulativeGroupedBulkPrice 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( + ReplacePricePriceCumulativeGroupedAllocation 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(NewPlanMinimumCompositePrice 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(ReplacePricePricePercent 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(ReplacePricePriceEventOutput value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + public ReplacePricePrice(JsonElement element) { - this._rawData = new(rawData); + this._element = element; } -#pragma warning restore CS8618 - /// - public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + /// 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) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + value = this.Value as NewPlanUnitPrice; + return value != null; } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + /// + /// 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) { - this.ReplacesPriceID = replacesPriceID; + value = this.Value as NewPlanTieredPrice; + return value != null; } -} - -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 + /// + /// 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 this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + value = this.Value as NewPlanBulkPrice; + return value != null; } - public string ItemID - { - 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 - ); - } + /// + /// 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 + ) + { + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != null; } - public string Name + /// + /// 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.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 - ); - } + value = this.Value as NewPlanPackagePrice; + return value != null; } - 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.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.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 NewPlanMatrixPrice; + 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.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.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 NewPlanThresholdTotalAmountPrice; + 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.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.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 NewPlanTieredPackagePrice; + 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.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.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 NewPlanTieredWithMinimumPrice; + 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.TryPickNewPlanGroupedTiered(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedTiered( + [NotNullWhen(true)] out NewPlanGroupedTieredPrice? 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 NewPlanGroupedTieredPrice; + 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.TryPickNewPlanTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackageWithMinimum( + [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? 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 NewPlanTieredPackageWithMinimumPrice; + 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.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? 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 NewPlanPackageWithAllocationPrice; + return value != null; } - public double? FixedPriceQuantity - { - 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 - ); - } - } - - public string? InvoiceGroupingKey - { - 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 - ); - } - } - - 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.TryPickNewPlanUnitWithPercent(out var value)) { + /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithPercent( + [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + ) { - 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 - ); - } + value = this.Value as NewPlanUnitWithPercentPrice; + 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.TryPickNewPlanMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + ) { - 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 - ); - } + value = this.Value as NewPlanMatrixWithAllocationPrice; + return value != null; } - 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.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(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.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(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.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(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) - { - 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) - { - value = this.Value as NewPlanPackagePrice; - 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.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) - { - value = this.Value as NewPlanMatrixPrice; - 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.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// 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 `ReplacePricePriceTieredWithProration` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value - ) + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - value = this.Value as 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; - } - - /// - /// 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.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; + 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.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" + ), + }; } - /// - /// 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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value - ) - { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; - } + 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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public override void Validate() { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - 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.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public virtual bool Equals(ReplacePricePrice? other) { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - 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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public override int GetHashCode() { - value = this.Value as NewPlanGroupedTieredPackagePrice; - 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? 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 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; - } - - /// - /// 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; - } - - /// - /// 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 - { - 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] - 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 - { - 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 + 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 ); @@ -13641,11 +11778,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -13665,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); } @@ -13742,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. /// @@ -13816,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" ); } @@ -13950,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(); @@ -13978,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 ) { @@ -14012,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 ) { @@ -14138,7 +12323,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -14146,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 ) { @@ -14234,7 +12409,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -14242,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; @@ -14279,7 +12520,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14288,7 +12529,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14297,7 +12538,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -14379,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" ); } } @@ -14415,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); @@ -14443,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); } @@ -14463,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 @@ -14531,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 ) { @@ -14548,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. /// @@ -14623,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. /// @@ -14682,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" ); } @@ -14817,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(); @@ -14844,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 ) { @@ -14880,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, @@ -14903,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 @@ -14914,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 ) { @@ -15038,7 +13341,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15046,8 +13349,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15055,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; @@ -15085,7 +13386,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15094,7 +13395,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15103,7 +13404,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15185,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" ); } } @@ -15221,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); @@ -15249,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); } @@ -15271,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 @@ -15339,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 ) { @@ -15358,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); } } /// @@ -15492,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" ); } @@ -15627,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") ) ) { @@ -15654,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 ) { @@ -15690,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, @@ -15713,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 @@ -15724,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 ) { @@ -15744,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)) ), @@ -15760,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 ) { @@ -15848,7 +14145,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -15856,8 +14153,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15865,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; @@ -15895,7 +14192,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15904,7 +14201,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15913,7 +14210,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -15995,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" ); } } @@ -16031,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); @@ -16059,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); @@ -16081,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 @@ -16149,7 +14446,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -16158,7 +14455,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -16167,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); } } /// @@ -16299,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" ); } @@ -16434,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"); } @@ -16456,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 ) { @@ -16488,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, @@ -16510,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 @@ -16521,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 ) { @@ -16541,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)) ), @@ -16557,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; @@ -16671,7 +15002,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16680,7 +15011,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16689,7 +15020,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16771,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" ); } } @@ -16807,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); @@ -16835,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); } @@ -16855,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 @@ -16923,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/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index ed52c032f..e8de0a1a0 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -979,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 @@ -1020,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 @@ -1061,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 @@ -1102,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 @@ -1143,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 @@ -1184,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 @@ -1225,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 @@ -1266,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 @@ -1307,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 @@ -1348,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 @@ -1389,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 @@ -1430,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 @@ -1471,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 @@ -1647,12 +1634,6 @@ public Price(CumulativeGroupedAllocation value, JsonElement? element = null) this._element = element; } - public Price(Minimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -2306,27 +2287,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 `Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) - { - value = this.Value as Minimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -2434,7 +2394,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -2471,7 +2430,6 @@ public void Switch( System::Action newPlanScalableMatrixWithTieredPricing, System::Action newPlanCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newPlanMinimumComposite, System::Action percent, System::Action eventOutput @@ -2563,9 +2521,6 @@ public void Switch( case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case Minimum value: - minimum(value); - break; case NewPlanMinimumCompositePrice value: newPlanMinimumComposite(value); break; @@ -2623,7 +2578,6 @@ public void Switch( /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -2666,7 +2620,6 @@ public T Match( > newPlanScalableMatrixWithTieredPricing, System::Func newPlanCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newPlanMinimumComposite, System::Func percent, System::Func eventOutput @@ -2707,7 +2660,6 @@ public T Match( newPlanScalableMatrixWithTieredPricing(value), NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - Minimum value => minimum(value), NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), Percent value => percent(value), EventOutput value => eventOutput(value), @@ -2775,8 +2727,6 @@ public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPric public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator Price(Minimum value) => new(value); - public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); public static implicit operator Price(Percent value) => new(value); @@ -2830,7 +2780,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() @@ -3497,25 +3446,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 @@ -6898,18 +6828,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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); } } @@ -6928,42 +6858,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required 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); } } /// @@ -7025,12 +6955,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" ); } @@ -7161,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(); @@ -7182,48 +7112,48 @@ public override void Validate() _ = this.ReferenceID; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(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 Minimum FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => - 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, @@ -7233,9 +7163,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 @@ -7243,19 +7173,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 ) { @@ -7263,12 +7193,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)) ), @@ -7279,93 +7209,71 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter(typeof(JsonModelConverter))] -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(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 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 MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - 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; @@ -7382,7 +7290,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7391,7 +7299,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7400,7 +7308,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -7482,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" ); } } @@ -7518,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 MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7546,13 +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(MinimumConversionRateConfig? other) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7566,9 +7474,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 @@ -7633,14 +7541,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -7648,22 +7556,35 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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>("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. /// @@ -7703,19 +7624,6 @@ 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. /// @@ -7775,12 +7683,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PercentConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7910,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(); @@ -7932,48 +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(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 Percent FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => - Percent.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -7983,9 +7896,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override PercentCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7993,19 +7906,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PercentCadence.Annual, - "semi_annual" => PercentCadence.SemiAnnual, - "monthly" => PercentCadence.Monthly, - "quarterly" => PercentCadence.Quarterly, - "one_time" => PercentCadence.OneTime, - "custom" => PercentCadence.Custom, - _ => (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, - PercentCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -8013,12 +7926,12 @@ JsonSerializerOptions options writer, value switch { - PercentCadence.Annual => "annual", - PercentCadence.SemiAnnual => "semi_annual", - PercentCadence.Monthly => "monthly", - PercentCadence.Quarterly => "quarterly", - PercentCadence.OneTime => "one_time", - 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)) ), @@ -8029,71 +7942,104 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for event_output pricing /// -[JsonConverter(typeof(JsonModelConverter))] -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(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 PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static EventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public PercentConfig(double percent) + public EventOutputConfig(string unitRatingKey) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class PercentConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - PercentConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8110,7 +8056,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8119,7 +8065,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8128,7 +8074,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -8210,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" ); } } @@ -8246,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 PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8274,13 +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(PercentConversionRateConfig? other) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -8294,9 +8240,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter : JsonConverter +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - public override PercentConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8361,14 +8308,14 @@ JsonSerializerOptions options } default: { - return new PercentConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PercentConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -8376,568 +8323,428 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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>("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 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); } + } + + /// + public override void Validate() + { + _ = this.AdjustmentID; + _ = this.PlanPhaseOrder; + } + + public RemoveAdjustment() { } + + public RemoveAdjustment(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 RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() + { + this.AdjustmentID = adjustmentID; } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// The id of the item the price will be associated with. + /// The id of the price to remove from the plan. /// - public required string ItemID + public required string PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass("price_id"); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("price_id", value); } } /// - /// The pricing model type + /// The phase to remove this price from. /// - public JsonElement ModelType + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("model_type", value); } + 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 name of the price. + /// The definition of a new adjustment to create and add to the plan. /// - public required string Name + public required ReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("adjustment"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// The id of the adjustment on the plan to replace in the plan. /// - public string? BillableMetricID + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("billable_metric_id", value); } + init { this._rawData.Set("replaces_adjustment_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. + /// The phase to replace this adjustment from. /// - public bool? BilledInAdvance + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("billed_in_advance", value); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; + _ = this.PlanPhaseOrder; } - /// - /// 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); } - } + public ReplaceAdjustment() { } - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public EventOutputConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency + public ReplaceAdjustment(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] + ReplaceAdjustment(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 ReplaceAdjustment 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 - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } +class ReplaceAdjustmentFromRaw : IFromRawJson +{ + /// + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); +} - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey +/// +/// 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 { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - 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 + public string? Currency { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" + 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("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 + public bool? IsInvoiceLevel { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel ); } } - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID + public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { - 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.Value = value; + this._element = element; } - public EventOutput() + public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.Value = value; + this._element = element; } - public EventOutput(EventOutput eventOutput) - : base(eventOutput) { } - - public EventOutput(IReadOnlyDictionary rawData) + public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) + public ReplaceAdjustmentAdjustment(JsonElement element) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this._element = element; } -} -class EventOutputFromRaw : IFromRawJson -{ - /// - public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutput.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(EventOutputCadenceConverter))] -public enum EventOutputCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class EventOutputCadenceConverter : JsonConverter -{ - public override EventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "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, - EventOutputCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); - } -} - -/// -/// Configuration for event_output pricing -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutputConfig : JsonModel -{ /// - /// The key in the event data to extract the unit rate from. + /// 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 required string UnitRatingKey + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); - } - init { this._rawData.Set("unit_rating_key", value); } + value = this.Value as NewPercentageDiscount; + return value != null; } /// - /// 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. + /// 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 string? DefaultUnitRate + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); - } - init { this._rawData.Set("default_unit_rate", value); } + value = this.Value as NewUsageDiscount; + return value != null; } /// - /// An optional key in the event data to group by (e.g., event ID). All events - /// will also be grouped by their unit rate. + /// 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 string? GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } - } - - /// - public override void Validate() - { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; - } - - public EventOutputConfig() { } - - public EventOutputConfig(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 EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() - { - this.UnitRatingKey = unitRatingKey; - } -} - -class EventOutputConfigFromRaw : IFromRawJson -{ - /// - public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(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 - ) - { - this.Value = value; - this._element = element; - } - - public EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public EventOutputConversionRateConfig(JsonElement element) + 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; } @@ -8955,28 +8762,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" ); } } @@ -8996,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 EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator 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 @@ -9040,13 +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(EventOutputConversionRateConfig? other) + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9060,33 +8902,32 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override 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 ); @@ -9104,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 ); @@ -9126,16 +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 EventOutputConversionRateConfig(element); + return new ReplaceAdjustmentAdjustment(element); } } } public override void Write( Utf8JsonWriter writer, - EventOutputConversionRateConfig value, + ReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { @@ -9143,24 +9044,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 { @@ -9172,230 +9086,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() + public string Name { - this.PriceID = priceID; + 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, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } -} - -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? BillableMetricID { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + 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("adjustment", value); } } - /// - /// The id of the adjustment on the plan to replace in the plan. - /// - public required string ReplacesAdjustmentID + public bool? BilledInAdvance { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + 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("replaces_adjustment_id", value); } } - /// - /// The phase to replace this adjustment from. - /// - public long? PlanPhaseOrder + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + 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 + ); } - init { this._rawData.Set("plan_phase_order", value); } } - /// - public override void Validate() - { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; - } - - 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 ); } } @@ -9405,4227 +9413,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) + 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(NewMinimum 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(NewMaximum value, JsonElement? element = null) + public string? InvoiceGroupingKey { - this.Value = value; - this._element = element; + 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 ReplaceAdjustmentAdjustment(JsonElement element) + 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, + 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, + 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; } - /// - /// 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 ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) { - value = this.Value as NewPercentageDiscount; - 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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) { - value = this.Value as NewUsageDiscount; - 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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public ReplacePricePrice(ReplacePricePriceBulkWithFilters 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(NewPlanPackagePrice 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(NewPlanMatrixPrice 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(NewPlanThresholdTotalAmountPrice 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(NewPlanTieredPackagePrice value, JsonElement? element = null) + { + 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 ) { - 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(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => - new(value); + public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => - new(value); + public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); + public ReplacePricePrice(NewPlanUnitWithProrationPrice 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(NewPlanGroupedAllocationPrice 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(NewPlanBulkWithProrationPrice 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( + NewPlanGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + public ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice 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( + ReplacePricePriceGroupedWithMinMaxThresholds 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(NewPlanMatrixWithDisplayNamePrice 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(NewPlanGroupedTieredPackagePrice 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 ReplaceAdjustmentAdjustment(element); - } - } + public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice 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( + NewPlanScalableMatrixWithTieredPricingPrice 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(NewPlanCumulativeGroupedBulkPrice 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( + ReplacePricePriceCumulativeGroupedAllocation 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(NewPlanMinimumCompositePrice 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(ReplacePricePricePercent 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(ReplacePricePriceEventOutput value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + public ReplacePricePrice(JsonElement element) { - this._rawData = new(rawData); + this._element = element; } -#pragma warning restore CS8618 - /// - public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + /// 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) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + value = this.Value as NewPlanUnitPrice; + return value != null; } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + /// + /// 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) { - this.ReplacesPriceID = replacesPriceID; + value = this.Value as NewPlanTieredPrice; + return value != null; } -} - -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 + /// + /// 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 this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + value = this.Value as NewPlanBulkPrice; + return value != null; } - public string ItemID - { - 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 - ); - } + /// + /// 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 + ) + { + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != null; } - public string Name + /// + /// 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.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 - ); - } + value = this.Value as NewPlanPackagePrice; + return value != null; } - 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.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.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 NewPlanMatrixPrice; + 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.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.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 NewPlanThresholdTotalAmountPrice; + 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.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.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 NewPlanTieredPackagePrice; + 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.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.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 NewPlanTieredWithMinimumPrice; + 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.TryPickNewPlanGroupedTiered(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedTiered( + [NotNullWhen(true)] out NewPlanGroupedTieredPrice? 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 NewPlanGroupedTieredPrice; + 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.TryPickNewPlanTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackageWithMinimum( + [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? 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 NewPlanTieredPackageWithMinimumPrice; + 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.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? 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 NewPlanPackageWithAllocationPrice; + return value != null; } - public double? FixedPriceQuantity - { - 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 - ); - } - } - - public string? InvoiceGroupingKey - { - 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 - ); - } - } - - 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.TryPickNewPlanUnitWithPercent(out var value)) { + /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithPercent( + [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + ) { - 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 - ); - } + value = this.Value as NewPlanUnitWithPercentPrice; + 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.TryPickNewPlanMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + ) { - 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 - ); - } + value = this.Value as NewPlanMatrixWithAllocationPrice; + return value != null; } - 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.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(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.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(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.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(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) - { - 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) - { - value = this.Value as NewPlanPackagePrice; - 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.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) - { - value = this.Value as NewPlanMatrixPrice; - 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.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// 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 `ReplacePricePriceTieredWithProration` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value - ) + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - value = this.Value as 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; - } - - /// - /// 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.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; + 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.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" + ), + }; } - /// - /// 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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value - ) - { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; - } + 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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public override void Validate() { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - 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.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public virtual bool Equals(ReplacePricePrice? other) { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - 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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public override int GetHashCode() { - value = this.Value as NewPlanGroupedTieredPackagePrice; - 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? 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 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; - } - - /// - /// 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; - } - - /// - /// 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 - { - 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] - 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 - { - 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 + 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 ); @@ -13643,11 +11780,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -13667,39 +11804,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); } @@ -13744,21 +11896,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. /// @@ -13818,12 +11955,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" ); } @@ -13952,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(); @@ -13980,33 +12117,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 ) { @@ -14014,124 +12256,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 ) { @@ -14140,7 +12325,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -14148,86 +12333,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 ) { @@ -14236,7 +12411,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -14244,27 +12419,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; @@ -14281,7 +12522,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14290,7 +12531,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14299,7 +12540,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -14381,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" ); } } @@ -14417,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 ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -14445,13 +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(ReplacePricePriceTieredWithProrationConversionRateConfig? other) + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -14465,10 +12706,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 @@ -14533,14 +12774,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -14550,42 +12791,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. /// @@ -14625,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. /// @@ -14684,12 +12925,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" ); } @@ -14819,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(); @@ -14846,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( - 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 ) { @@ -14882,20 +13121,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, @@ -14905,10 +13144,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 @@ -14916,122 +13155,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 ) { @@ -15040,7 +13343,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15048,8 +13351,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15057,20 +13360,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; @@ -15087,7 +13388,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15096,7 +13397,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15105,7 +13406,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15187,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" ); } } @@ -15223,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15251,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( - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -15273,10 +13572,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 @@ -15341,16 +13640,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -15360,40 +13657,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); } } /// @@ -15494,12 +13791,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" ); } @@ -15629,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") ) ) { @@ -15656,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( - 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 ) { @@ -15692,20 +13989,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, @@ -15715,10 +14012,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 @@ -15726,19 +14023,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 ) { @@ -15746,12 +14043,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)) ), @@ -15762,86 +14059,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 ) { @@ -15850,7 +14147,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -15858,8 +14155,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15867,20 +14164,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; @@ -15897,7 +14194,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15906,7 +14203,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15915,7 +14212,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -15997,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" ); } } @@ -16033,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16061,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( - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -16083,10 +14380,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 @@ -16151,7 +14448,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -16160,7 +14457,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -16169,51 +14466,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); } } /// @@ -16301,12 +14601,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" ); } @@ -16436,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"); } @@ -16458,31 +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(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 ) { @@ -16490,19 +14799,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, @@ -16512,10 +14822,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 @@ -16523,19 +14833,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 ) { @@ -16543,12 +14853,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)) ), @@ -16559,104 +14869,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; @@ -16673,7 +15004,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16682,7 +15013,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16691,7 +15022,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16773,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" ); } } @@ -16809,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 ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16837,13 +15168,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); } @@ -16857,10 +15190,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 @@ -16925,14 +15258,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/Plans/Plan.cs b/src/Orb/Models/Plans/Plan.cs index b0a7fea4e..7f23294a9 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 0aea030a0..1f6b3e725 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -433,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 @@ -474,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 @@ -515,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 @@ -556,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 @@ -597,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 @@ -638,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 @@ -679,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 @@ -720,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 @@ -761,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 @@ -802,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 @@ -843,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 @@ -884,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 @@ -925,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 @@ -1104,12 +1091,6 @@ public PricePrice(CumulativeGroupedAllocation value, JsonElement? element = null this._element = element; } - public PricePrice(Minimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public PricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -1763,27 +1744,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 `Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) - { - value = this.Value as Minimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -1891,7 +1851,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -1928,7 +1887,6 @@ public void Switch( System::Action newPlanScalableMatrixWithTieredPricing, System::Action newPlanCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newPlanMinimumComposite, System::Action percent, System::Action eventOutput @@ -2020,9 +1978,6 @@ public void Switch( case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case Minimum value: - minimum(value); - break; case NewPlanMinimumCompositePrice value: newPlanMinimumComposite(value); break; @@ -2080,7 +2035,6 @@ public void Switch( /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -2123,7 +2077,6 @@ public T Match( > newPlanScalableMatrixWithTieredPricing, System::Func newPlanCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newPlanMinimumComposite, System::Func percent, System::Func eventOutput @@ -2164,7 +2117,6 @@ public T Match( newPlanScalableMatrixWithTieredPricing(value), NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - Minimum value => minimum(value), NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), Percent value => percent(value), EventOutput value => eventOutput(value), @@ -2240,8 +2192,6 @@ public static implicit operator PricePrice(NewPlanCumulativeGroupedBulkPrice val public static implicit operator PricePrice(CumulativeGroupedAllocation value) => new(value); - public static implicit operator PricePrice(Minimum value) => new(value); - public static implicit operator PricePrice(NewPlanMinimumCompositePrice value) => new(value); public static implicit operator PricePrice(Percent value) => new(value); @@ -2295,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() @@ -2962,25 +2911,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 @@ -6367,756 +6297,6 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Minimum : 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); } - } - - /// - /// 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 MinimumConfig 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 MinimumConversionRateConfig? 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; - 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.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public Minimum() - { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - - public Minimum(Minimum minimum) - : base(minimum) { } - - public Minimum(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static Minimum FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class MinimumFromRaw : IFromRawJson -{ - /// - public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => - Minimum.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class MinimumCadenceConverter : JsonConverter -{ - public override MinimumCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - MinimumCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - MinimumCadence.Annual => "annual", - MinimumCadence.SemiAnnual => "semi_annual", - MinimumCadence.Monthly => "monthly", - MinimumCadence.Quarterly => "quarterly", - MinimumCadence.OneTime => "one_time", - MinimumCadence.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 MinimumConfig : 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 MinimumConfig() { } - - public MinimumConfig(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 MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } -} - -class MinimumConfigFromRaw : IFromRawJson -{ - /// - public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - 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))] public sealed record class Percent : JsonModel { diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index 9a7e02212..f71357d6a 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/PriceCreateParams.cs b/src/Orb/Models/Prices/PriceCreateParams.cs index 7fd431e4b..5f126121b 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -207,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 @@ -248,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 @@ -289,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 @@ -330,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 @@ -371,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 @@ -412,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 @@ -453,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 @@ -496,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 @@ -537,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 @@ -578,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 @@ -619,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 @@ -661,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 @@ -837,12 +825,6 @@ public Body(CumulativeGroupedAllocation value, JsonElement? element = null) this._element = element; } - public Body(Minimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public Body(NewFloatingMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -1500,27 +1482,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 `Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) - { - value = this.Value as Minimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -1628,7 +1589,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -1665,7 +1625,6 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricingPrice, System::Action newFloatingCumulativeGroupedBulkPrice, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newFloatingMinimumCompositePrice, System::Action percent, System::Action eventOutput @@ -1757,9 +1716,6 @@ public void Switch( case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case Minimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumCompositePrice(value); break; @@ -1817,7 +1773,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -1881,7 +1836,6 @@ public T Match( T > newFloatingCumulativeGroupedBulkPrice, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newFloatingMinimumCompositePrice, System::Func percent, System::Func eventOutput @@ -1936,7 +1890,6 @@ public T Match( value ), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - Minimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumCompositePrice(value), Percent value => percent(value), EventOutput value => eventOutput(value), @@ -2005,8 +1958,6 @@ public static implicit operator Body(NewFloatingScalableMatrixWithTieredPricingP public static implicit operator Body(CumulativeGroupedAllocation value) => new(value); - public static implicit operator Body(Minimum value) => new(value); - public static implicit operator Body(NewFloatingMinimumCompositePrice value) => new(value); public static implicit operator Body(Percent value) => new(value); @@ -2070,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() @@ -2745,25 +2695,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 @@ -5263,740 +5194,6 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Minimum : 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 MinimumConfig 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 MinimumConversionRateConfig? 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 Minimum() - { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - - public Minimum(Minimum minimum) - : base(minimum) { } - - public Minimum(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static Minimum FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class MinimumFromRaw : IFromRawJson -{ - /// - public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => - Minimum.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class MinimumCadenceConverter : JsonConverter -{ - public override MinimumCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - MinimumCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - MinimumCadence.Annual => "annual", - MinimumCadence.SemiAnnual => "semi_annual", - MinimumCadence.Monthly => "monthly", - MinimumCadence.Quarterly => "quarterly", - MinimumCadence.OneTime => "one_time", - MinimumCadence.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 MinimumConfig : 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 MinimumConfig() { } - - public MinimumConfig(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 MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } -} - -class MinimumConfigFromRaw : IFromRawJson -{ - /// - public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - 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))] public sealed record class Percent : JsonModel { diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs index 4222479d1..ab6cca778 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -411,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 @@ -452,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 @@ -493,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 @@ -534,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 @@ -575,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 @@ -616,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 @@ -657,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 @@ -698,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 @@ -739,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 @@ -780,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 @@ -821,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 @@ -862,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 @@ -1038,12 +1026,6 @@ public Price(PriceCumulativeGroupedAllocation value, JsonElement? element = null this._element = element; } - public Price(PriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public Price(NewFloatingMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -1699,27 +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 `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 . @@ -1827,7 +1788,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (PriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PricePercent value) => {...}, /// (PriceEventOutput value) => {...} @@ -1864,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 @@ -1956,9 +1915,6 @@ public void Switch( case PriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -2016,7 +1972,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (PriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PricePercent value) => {...}, /// (PriceEventOutput value) => {...} @@ -2068,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 @@ -2111,7 +2065,6 @@ public T Match( newFloatingScalableMatrixWithTieredPricing(value), NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceMinimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PricePercent value => percent(value), PriceEventOutput value => eventOutput(value), @@ -2184,8 +2137,6 @@ public static implicit operator Price(NewFloatingCumulativeGroupedBulkPrice valu public static implicit operator Price(PriceCumulativeGroupedAllocation value) => new(value); - public static implicit operator Price(PriceMinimum value) => new(value); - public static implicit operator Price(NewFloatingMinimumCompositePrice value) => new(value); public static implicit operator Price(PricePercent value) => new(value); @@ -2241,7 +2192,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() @@ -2916,25 +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 @@ -5523,746 +5454,6 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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>("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 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(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 PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PriceMinimumFromRaw : IFromRawJson -{ - /// - public PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => - PriceMinimum.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PriceMinimumCadenceConverter : JsonConverter -{ - public override PriceMinimumCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => PriceMinimumCadence.Annual, - "semi_annual" => PriceMinimumCadence.SemiAnnual, - "monthly" => PriceMinimumCadence.Monthly, - "quarterly" => PriceMinimumCadence.Quarterly, - "one_time" => PriceMinimumCadence.OneTime, - "custom" => PriceMinimumCadence.Custom, - _ => (PriceMinimumCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - PriceMinimumCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - PriceMinimumCadence.Annual => "annual", - PriceMinimumCadence.SemiAnnual => "semi_annual", - PriceMinimumCadence.Monthly => "monthly", - PriceMinimumCadence.Quarterly => "quarterly", - PriceMinimumCadence.OneTime => "one_time", - 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(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 PriceMinimumConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator 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(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 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 PriceMinimumConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - 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/PriceEvaluatePreviewEventsParams.cs b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs index 8f38fedea..4af110327 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs @@ -564,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 @@ -605,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 @@ -646,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 @@ -687,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 @@ -728,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 @@ -769,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 @@ -810,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 @@ -851,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 @@ -892,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 @@ -933,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 @@ -974,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 @@ -1015,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 @@ -1275,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 @@ -1957,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 . @@ -2092,7 +2048,6 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput? value /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} @@ -2129,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 @@ -2221,9 +2175,6 @@ public void Switch( case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -2283,7 +2234,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} @@ -2344,7 +2294,6 @@ public T Match( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -2390,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( @@ -2514,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); @@ -2581,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() @@ -3260,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 @@ -6045,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/Subscriptions/SubscriptionCreateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs index e5bec34b4..96de90d5f 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -1674,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 @@ -1715,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 @@ -1756,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 @@ -1797,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 @@ -1838,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 @@ -1879,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 @@ -1920,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 @@ -1963,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 @@ -2004,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 @@ -2045,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 @@ -2086,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 @@ -2128,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 @@ -2169,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 @@ -2351,12 +2338,6 @@ public Price(CumulativeGroupedAllocation value, JsonElement? element = null) this._element = element; } - public Price(Minimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public Price(NewSubscriptionMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -3016,27 +2997,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 `Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out Minimum? value) - { - value = this.Value as Minimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -3144,7 +3104,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -3181,7 +3140,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 @@ -3273,9 +3231,6 @@ public void Switch( case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case Minimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; @@ -3333,7 +3288,6 @@ public void Switch( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (Minimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -3406,7 +3360,6 @@ public T Match( T > newSubscriptionCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func eventOutput @@ -3461,7 +3414,6 @@ public T Match( value ), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - Minimum value => minimum(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), Percent value => percent(value), EventOutput value => eventOutput(value), @@ -3543,8 +3495,6 @@ public static implicit operator Price(NewSubscriptionCumulativeGroupedBulkPrice public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator Price(Minimum value) => new(value); - public static implicit operator Price(NewSubscriptionMinimumCompositePrice value) => new(value); public static implicit operator Price(Percent value) => new(value); @@ -3605,7 +3555,6 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() @@ -4282,25 +4231,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 @@ -7684,18 +7614,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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); } } @@ -7714,42 +7644,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required 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); } } /// @@ -7811,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" ); } @@ -7947,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(); @@ -7968,48 +7898,48 @@ public override void Validate() _ = this.ReferenceID; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(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 Minimum FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public Minimum FromRawUnchecked(IReadOnlyDictionary rawData) => - 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, @@ -8019,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 @@ -8029,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 ) { @@ -8049,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)) ), @@ -8065,93 +7995,71 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter(typeof(JsonModelConverter))] -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(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 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 MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - 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; @@ -8168,7 +8076,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8177,7 +8085,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8186,7 +8094,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -8268,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" ); } } @@ -8304,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); @@ -8332,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); } @@ -8352,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 @@ -8419,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 ) { @@ -8434,22 +8342,35 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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>("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. /// @@ -8489,19 +8410,6 @@ 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. /// @@ -8561,12 +8469,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PercentConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8696,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(); @@ -8718,48 +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(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 Percent FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => - Percent.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -8769,9 +8682,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override PercentCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8779,19 +8692,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PercentCadence.Annual, - "semi_annual" => PercentCadence.SemiAnnual, - "monthly" => PercentCadence.Monthly, - "quarterly" => PercentCadence.Quarterly, - "one_time" => PercentCadence.OneTime, - "custom" => PercentCadence.Custom, - _ => (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, - PercentCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -8799,14 +8712,14 @@ JsonSerializerOptions options writer, value switch { - 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)) + 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)) ), }, options @@ -8815,71 +8728,104 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for event_output pricing /// -[JsonConverter(typeof(JsonModelConverter))] -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(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 PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static EventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public PercentConfig(double percent) + public EventOutputConfig(string unitRatingKey) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class PercentConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - PercentConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8896,7 +8842,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8905,7 +8851,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8914,7 +8860,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -8996,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" ); } } @@ -9032,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 PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9060,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(PercentConversionRateConfig? other) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9080,9 +9026,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter : JsonConverter +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - public override PercentConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9147,14 +9094,14 @@ JsonSerializerOptions options } default: { - return new PercentConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PercentConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -9162,607 +9109,495 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -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>("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 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; + } + + public RemoveAdjustment() { } + + public RemoveAdjustment(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 RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() + { + this.AdjustmentID = adjustmentID; } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// The name of the price. + /// The external price id of the price to remove on the subscription. /// - public required string Name + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// The id of the price to remove on the subscription. /// - public string? BillableMetricID + public string? PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); + return this._rawData.GetNullableClass("price_id"); } - init { this._rawData.Set("billable_metric_id", value); } + init { this._rawData.Set("price_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 + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } + _ = this.ExternalPriceID; + _ = this.PriceID; } - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + public RemovePrice() { } + + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } + + public RemovePrice(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } + this._rawData = new(rawData); } - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemovePrice(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public EventOutputConversionRateConfig? ConversionRateConfig + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } + 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 ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. + /// The definition of a new adjustment to create and add to the subscription. /// - public string? Currency + public required ReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); + return this._rawData.GetNotNullClass("adjustment"); } - init { this._rawData.Set("currency", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// For dimensional price: specifies a price group and dimension values + /// The id of the adjustment on the plan to replace in the subscription. /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("dimensional_price_configuration", value); } + init { this._rawData.Set("replaces_adjustment_id", value); } } - /// - /// An alias for the price. - /// - public string? ExternalPriceID + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; } - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity + public ReplaceAdjustment() { } + + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } + + public ReplaceAdjustment(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + this._rawData = new(rawData); } - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplaceAdjustment(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// 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 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 { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions ); } - 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 + public string? Currency { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + return Match( + newPercentageDiscount: (x) => x.Currency, + newUsageDiscount: (x) => x.Currency, + newAmountDiscount: (x) => x.Currency, + newMinimum: (x) => x.Currency, + newMaximum: (x) => x.Currency ); } } - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID + public bool? IsInvoiceLevel { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); + 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("reference_id", value); } } - /// - public override void Validate() + public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) { - 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.Value = value; + this._element = element; } - public EventOutput() + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.Value = value; + this._element = element; } - public EventOutput(EventOutput eventOutput) - : base(eventOutput) { } - - public EventOutput(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class EventOutputFromRaw : IFromRawJson -{ - /// - public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutput.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(EventOutputCadenceConverter))] -public enum EventOutputCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class EventOutputCadenceConverter : JsonConverter -{ - public override EventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "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, - EventOutputCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); - } -} - -/// -/// Configuration for event_output pricing -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutputConfig : JsonModel -{ - /// - /// The key in the event data to extract the unit rate from. - /// - public required string UnitRatingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); - } - 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.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; - } - - public EventOutputConfig() { } - - public EventOutputConfig(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 EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() - { - this.UnitRatingKey = unitRatingKey; - } -} - -class EventOutputConfigFromRaw : IFromRawJson -{ - /// - public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(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 void Switch( - System::Action unit, - System::Action tiered + 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 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" ); } } @@ -9782,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 EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator 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 @@ -9826,13 +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(EventOutputConversionRateConfig? other) + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9846,33 +9701,32 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override 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 ); @@ -9890,11 +9744,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 ); @@ -9912,16 +9788,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 EventOutputConversionRateConfig(element); + return new ReplaceAdjustmentAdjustment(element); } } } public override void Write( Utf8JsonWriter writer, - EventOutputConversionRateConfig value, + ReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { @@ -9929,122 +9843,58 @@ JsonSerializerOptions options } } -[System::Obsolete("deprecated")] -[JsonConverter(typeof(ExternalMarketplaceConverter))] -public enum ExternalMarketplace -{ - Google, - Aws, - Azure, -} - -sealed class ExternalMarketplaceConverter : JsonConverter +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : JsonModel { - public override ExternalMarketplace Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// The id of the price on the plan to replace in the subscription. + /// + public required string ReplacesPriceID { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "google" => ExternalMarketplace.Google, - "aws" => ExternalMarketplace.Aws, - "azure" => ExternalMarketplace.Azure, - _ => (ExternalMarketplace)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ExternalMarketplace 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_price_id"); + } + init { this._rawData.Set("replaces_price_id", value); } } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel -{ /// - /// The id of the adjustment to remove on the subscription. + /// The definition of a new allocation price to create and add to the subscription. /// - public required string AdjustmentID + public NewAllocationPrice? AllocationPrice { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNullableClass("allocation_price"); } - init { this._rawData.Set("adjustment_id", value); } - } - - /// - public override void Validate() - { - _ = this.AdjustmentID; - } - - public RemoveAdjustment() { } - - public RemoveAdjustment(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 RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + init { this._rawData.Set("allocation_price", value); } } - [SetsRequiredMembers] - public RemoveAdjustment(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 RemoveAdjustmentFromRaw : IFromRawJson -{ - /// - public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - RemoveAdjustment.FromRawUnchecked(rawData); -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemovePrice : 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 { @@ -10057,132 +9907,135 @@ 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); } - } - - /// - public override void Validate() - { - _ = this.ExternalPriceID; - _ = this.PriceID; - } - - public RemovePrice() { } - - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); + init { this._rawData.Set("fixed_price_quantity", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MaximumAmount { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maximum_amount"); + } + init { this._rawData.Set("maximum_amount", value); } } -#pragma warning restore CS8618 - /// - public static RemovePrice 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 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 subscription. + /// New subscription price request body params. /// - public required ReplaceAdjustmentAdjustment Adjustment + public ReplacePricePrice? 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 ReplaceAdjustment() { } + public ReplacePrice() { } - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } - public ReplaceAdjustment(IReadOnlyDictionary rawData) + public ReplacePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + ReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePrice(string replacesPriceID) + : this() + { + this.ReplacesPriceID = replacesPriceID; + } } -class ReplaceAdjustmentFromRaw : IFromRawJson +class ReplacePriceFromRaw : IFromRawJson { /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the subscription. +/// New subscription price request body params. /// -[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase { public object? Value { get; } = null; @@ -10199,4439 +10052,2723 @@ 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 - ); - } - } - - public bool? IsInvoiceLevel - { - 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.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 ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + public string Name { - this.Value = value; - this._element = 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, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } - public ReplaceAdjustmentAdjustment(NewUsageDiscount 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 ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) + public bool? BilledInAdvance { - 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 ReplaceAdjustmentAdjustment(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 ReplaceAdjustmentAdjustment(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 ReplaceAdjustmentAdjustment(JsonElement element) + public string? Currency { - 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) - { - value = this.Value as NewPercentageDiscount; - return value != null; + 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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewUsageDiscount; - 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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public string? ExternalPriceID { - 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; - } - - /// - /// 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 - ) - { - 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.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 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 NewBillingCycleConfiguration? InvoicingCycleConfiguration { - 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 ReplaceAdjustmentAdjustment" - ), - }; + 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 + ); + } } - public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount 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 - /// (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 string? ReferenceID { - if (this.Value == null) + get { - 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 ); } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) + public ReplacePricePrice(NewSubscriptionUnitPrice 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(NewSubscriptionTieredPrice value, JsonElement? element = null) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + public ReplacePricePrice(NewSubscriptionBulkPrice 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(ReplacePricePriceBulkWithFilters 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 - } - - 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 - } + public ReplacePricePrice(NewSubscriptionPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - default: - { - return new ReplaceAdjustmentAdjustment(element); - } - } + public ReplacePricePrice(NewSubscriptionMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public ReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice 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(NewSubscriptionTieredPackagePrice 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( + NewSubscriptionTieredWithMinimumPrice 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(NewSubscriptionGroupedTieredPrice 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( + NewSubscriptionTieredPackageWithMinimumPrice 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( + NewSubscriptionPackageWithAllocationPrice 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(NewSubscriptionUnitWithPercentPrice 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( + NewSubscriptionMatrixWithAllocationPrice 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( + ReplacePricePriceTieredWithProration 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( + NewSubscriptionUnitWithProrationPrice 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( + NewSubscriptionGroupedAllocationPrice 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 ReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } + public ReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - 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 + /// + /// 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.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 NewSubscriptionThresholdTotalAmountPrice; + 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.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.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; + value = this.Value as NewSubscriptionTieredPackagePrice; + return value != null; } - 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.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(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.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(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.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(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.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(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.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( - 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.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 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.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( - 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.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 ReplacePricePrice(NewSubscriptionGroupedTieredPrice 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; - } - - 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 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.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` + /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + public bool TryPickNewSubscriptionBulkWithProration( + [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value + ) { - value = this.Value as NewSubscriptionUnitPrice; + 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.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` + /// if (instance.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + public bool TryPickNewSubscriptionGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value ) { - value = this.Value as NewSubscriptionTieredPrice; + 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.TryPickNewSubscriptionBulk(out var value)) { - /// // `value` is of type `NewSubscriptionBulkPrice` + /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value + ) { - value = this.Value as NewSubscriptionBulkPrice; + 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.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.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` + /// if (instance.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value + public bool TryPickNewSubscriptionMatrixWithDisplayName( + [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value ) { - value = this.Value as NewSubscriptionPackagePrice; + 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.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` + /// if (instance.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value - ) - { - value = this.Value as NewSubscriptionMatrixPrice; - 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.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value - ) - { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; - 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.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value + public bool TryPickNewSubscriptionGroupedTieredPackage( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value ) { - value = this.Value as NewSubscriptionTieredPackagePrice; + 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + public bool TryPickNewSubscriptionMaxGroupTieredPackage( + [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value ) { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; + 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.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value ) { - value = this.Value as NewSubscriptionGroupedTieredPrice; + 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.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value ) { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + 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.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value + public bool TryPickNewSubscriptionCumulativeGroupedBulk( + [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value ) { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; + 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.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value ) { - value = this.Value as NewSubscriptionUnitWithPercentPrice; + 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.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` + /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { + /// // `value` is of type `NewSubscriptionMinimumCompositePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value + public bool TryPickNewSubscriptionMinimumComposite( + [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value ) { - value = this.Value as NewSubscriptionMatrixWithAllocationPrice; + 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.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `ReplacePricePriceTieredWithProration` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value - ) + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - value = this.Value as 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.TryPickNewSubscriptionUnitWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `ReplacePricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnitWithProration( - [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - value = this.Value as NewSubscriptionUnitWithProrationPrice; + 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.TryPickNewSubscriptionGroupedAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedAllocation( - [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value - ) - { - 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 . + /// 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.TryPickNewSubscriptionBulkWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` - /// 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 TryPickNewSubscriptionBulkWithProration( - [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? 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 NewSubscriptionBulkWithProrationPrice; - 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.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; + 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 . + /// 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.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` - /// 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 TryPickNewSubscriptionGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? 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 NewSubscriptionGroupedWithMeteredMinimumPrice; - 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.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; + 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.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 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.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(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.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(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.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(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.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(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.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(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.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( + 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.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(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.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( + 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.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(NewSubscriptionGroupedTieredPrice 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( + 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 ); @@ -14649,11 +12786,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14673,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); } @@ -14750,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. /// @@ -14824,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" ); } @@ -14958,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(); @@ -14986,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 ) { @@ -15020,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 ) { @@ -15146,7 +13331,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -15154,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 ) { @@ -15242,7 +13417,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -15250,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; @@ -15287,7 +13528,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15296,7 +13537,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15305,7 +13546,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -15387,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" ); } } @@ -15423,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); @@ -15451,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); } @@ -15471,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 @@ -15539,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 ) { @@ -15556,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. /// @@ -15631,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. /// @@ -15690,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" ); } @@ -15825,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(); @@ -15852,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 ) { @@ -15888,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, @@ -15911,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 @@ -15922,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 ) { @@ -16046,7 +14349,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -16054,8 +14357,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16063,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; @@ -16093,7 +14394,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16102,7 +14403,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16111,7 +14412,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16193,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" ); } } @@ -16229,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); @@ -16257,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); } @@ -16279,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 @@ -16347,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 ) { @@ -16366,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); } } /// @@ -16500,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" ); } @@ -16635,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") ) ) { @@ -16662,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 ) { @@ -16698,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, @@ -16721,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 @@ -16732,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 ) { @@ -16752,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)) ), @@ -16768,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 ) { @@ -16856,7 +15153,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16864,8 +15161,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16873,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; @@ -16903,7 +15200,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16912,7 +15209,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16921,7 +15218,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -17003,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" ); } } @@ -17039,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); @@ -17067,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); @@ -17089,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 @@ -17157,7 +15454,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -17166,7 +15463,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -17175,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); } } /// @@ -17307,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" ); } @@ -17442,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"); } @@ -17464,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 ) { @@ -17496,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, @@ -17518,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 @@ -17529,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 ) { @@ -17549,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)) ), @@ -17565,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; @@ -17679,7 +16010,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17688,7 +16019,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17697,7 +16028,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -17779,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" ); } } @@ -17815,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); @@ -17843,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); } @@ -17863,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 @@ -17931,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/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index 6e31d5265..6571a67ac 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -1789,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 @@ -1830,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 @@ -1871,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 @@ -1912,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 @@ -1953,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 @@ -1994,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 @@ -2035,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 @@ -2076,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 @@ -2117,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 @@ -2158,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 @@ -2199,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 @@ -2240,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 @@ -2422,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; @@ -3083,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 . @@ -3211,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) => {...} @@ -3248,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 @@ -3340,9 +3299,6 @@ public void Switch( case PriceModelCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceModelMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -3400,7 +3356,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceModelPercent value) => {...}, /// (PriceModelEventOutput value) => {...} @@ -3452,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 @@ -3495,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), @@ -3580,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); @@ -3638,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() @@ -4315,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 @@ -6945,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/SubscriptionSchedulePlanChangeParams.cs b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs index 7a5bd8667..f17728688 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -1676,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 @@ -1717,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 @@ -1758,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 @@ -1799,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 @@ -1840,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 @@ -1881,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 @@ -1922,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 @@ -1965,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 @@ -2006,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 @@ -2047,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 @@ -2088,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 @@ -2130,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 @@ -2171,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 @@ -2431,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 @@ -3120,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 . @@ -3254,7 +3209,6 @@ public bool TryPickEventOutput( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} @@ -3291,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 @@ -3383,9 +3336,6 @@ public void Switch( case SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; @@ -3445,7 +3395,6 @@ public void Switch( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} @@ -3530,7 +3479,6 @@ public T Match( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func eventOutput @@ -3589,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( @@ -3713,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); @@ -3785,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() @@ -4467,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 @@ -8215,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); } @@ -8253,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); } } /// @@ -8352,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" ); } @@ -8488,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(); @@ -8509,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 ) { @@ -8538,8 +8457,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8547,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, @@ -8570,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 @@ -8581,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 ) { @@ -8603,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)) ), @@ -8623,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 ) { @@ -8691,7 +8588,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( FrozenDictionary rawData ) { @@ -8699,8 +8596,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8708,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; @@ -8750,7 +8645,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8759,7 +8654,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8768,7 +8663,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( JsonElement element ) { @@ -8852,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" ); } } @@ -8888,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); @@ -8916,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); @@ -8938,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 @@ -9006,7 +8901,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( element ); } @@ -9015,7 +8910,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -9025,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. /// @@ -9088,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. /// @@ -9162,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" ); } @@ -9297,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(); @@ -9319,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 ) { @@ -9348,8 +9248,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9357,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, @@ -9380,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 @@ -9391,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 ) { @@ -9413,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)) ), @@ -9433,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 ) { @@ -9479,7 +9416,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( FrozenDictionary rawData ) { @@ -9487,8 +9424,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9496,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; @@ -9536,7 +9475,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9545,7 +9484,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9554,7 +9493,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( JsonElement element ) { @@ -9638,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" ); } } @@ -9674,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); @@ -9702,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); @@ -9724,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 @@ -9792,7 +9731,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( element ); } @@ -9801,7 +9740,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -9809,329 +9748,275 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput : JsonModel +/// +/// 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 { - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum< - string, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > Cadence + Unchanged, + PlanChangeDate, + StartOfMonth, +} + +sealed class BillingCycleAlignmentConverter : JsonConverter +{ + public override BillingCycleAlignment 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); } + "unchanged" => BillingCycleAlignment.Unchanged, + "plan_change_date" => BillingCycleAlignment.PlanChangeDate, + "start_of_month" => BillingCycleAlignment.StartOfMonth, + _ => (BillingCycleAlignment)(-1), + }; } - /// - /// Configuration for event_output pricing - /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig EventOutputConfig + public override void Write( + Utf8JsonWriter writer, + BillingCycleAlignment 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 + { + 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 + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsRemoveAdjustment : 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 - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } - /// - /// 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); } - } + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment + ) + : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } - /// - /// 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 SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } + this._rawData = new(rawData); } - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + FrozenDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate + /// + public static SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? ConversionRateConfig + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment(string adjustmentID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", 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 +{ /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. + /// The external price id of the price to remove on the subscription. /// - public string? Currency + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("currency", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// For dimensional price: specifies a price group and dimension values + /// The id of the price to remove on the subscription. /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public string? PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); + return this._rawData.GetNullableClass("price_id"); } - init { this._rawData.Set("dimensional_price_configuration", value); } + init { this._rawData.Set("price_id", value); } } - /// - /// An alias for the price. - /// - public string? ExternalPriceID + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + _ = this.ExternalPriceID; + _ = this.PriceID; } - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity + public SubscriptionSchedulePlanChangeParamsRemovePrice() { } + + public SubscriptionSchedulePlanChangeParamsRemovePrice( + SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice + ) + : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } + + public SubscriptionSchedulePlanChangeParamsRemovePrice( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + this._rawData = new(rawData); } - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsRemovePrice(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// 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 static SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_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 +{ /// - /// 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 definition of a new adjustment to create and add to the subscription. /// - public IReadOnlyDictionary? Metadata + public required SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + return this._rawData.GetNotNullClass( + "adjustment" ); } + init { this._rawData.Set("adjustment", value); } } /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. + /// The id of the adjustment on the plan to replace in the subscription. /// - public string? ReferenceID + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); + return this._rawData.GetNotNullClass("replaces_adjustment_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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() - { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); - } + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment() { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } + : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + SubscriptionSchedulePlanChangeParamsReplaceAdjustment( FrozenDictionary rawData ) { @@ -10139,8 +10024,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -10148,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 - ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } - - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - IReadOnlyDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewUsageDiscount value, + JsonElement? element = null ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - FrozenDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewAmountDiscount value, + JsonElement? element = null ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#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; + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) + { + this._element = element; + } - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - 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; } @@ -10447,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" ); } } @@ -10488,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); /// @@ -10532,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); @@ -10554,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 ); @@ -10598,11 +10453,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10620,176 +10475,211 @@ JsonSerializerOptions options return new(element); } - default: + case "amount_discount": { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - 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, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, 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, -} + 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 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), - }; + return new(element); + } + default: + { + return new SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(element); + } + } } public override void Write( Utf8JsonWriter writer, - BillingCycleAlignment value, + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment 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 - ); + JsonSerializer.Serialize(writer, value.Json, 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); } + 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 SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment - ) - : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - 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] - SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - 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 SubscriptionSchedulePlanChangeParamsRemoveAdjustment 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 SubscriptionSchedulePlanChangeParamsRemoveAdjustment(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 SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsRemoveAdjustment.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< - SubscriptionSchedulePlanChangeParamsRemovePrice, - SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsRemovePrice : JsonModel -{ /// - /// The external price id of the price to remove on the subscription. + /// New subscription price request body params. /// - public string? ExternalPriceID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice? 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 { @@ -10804,18 +10694,28 @@ 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 SubscriptionSchedulePlanChangeParamsRemovePrice() { } + public SubscriptionSchedulePlanChangeParamsReplacePrice() { } - public SubscriptionSchedulePlanChangeParamsRemovePrice( - SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice + public SubscriptionSchedulePlanChangeParamsReplacePrice( + SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice ) - : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } + : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } - public SubscriptionSchedulePlanChangeParamsRemovePrice( + public SubscriptionSchedulePlanChangeParamsReplacePrice( IReadOnlyDictionary rawData ) { @@ -10824,120 +10724,42 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsRemovePrice(FrozenDictionary rawData) + SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( IReadOnlyDictionary rawData ) { 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 -{ - /// - /// The definition of a new adjustment to create and add to the subscription. - /// - public required SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment 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 subscription. - /// - public required string ReplacesAdjustmentID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); - } - init { this._rawData.Set("replaces_adjustment_id", value); } - } - - /// - public override void Validate() - { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment() { } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment - ) - : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) + : this() { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + 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; @@ -10954,1266 +10776,792 @@ 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 - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum 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(JsonElement element) + public bool? BilledInAdvance { - 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) - { - value = this.Value as NewPercentageDiscount; - return value != 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, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as NewUsageDiscount; - return value != null; + 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 + ); + } } - /// - /// 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? ConversionRate { - value = this.Value as NewAmountDiscount; - return value != null; + 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 + ); + } } - /// - /// 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? Currency { - value = this.Value as NewMinimum; - return value != null; + 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.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - 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 newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum - ) - { - 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.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 + ); } } - /// - /// 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? ExternalPriceID { - 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.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 + ); + } } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value - ) => new(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); - - /// - /// 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 double? FixedPriceQuantity { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + 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 ); } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); } - public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? 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 SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public string? InvoiceGroupingKey { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try + get { - 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 - } - - return new(element); - } - default: - { - return new SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(element); - } + 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 + ); } } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -[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 NewBillingCycleConfiguration? InvoicingCycleConfiguration { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); + 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 + ); } - init { this._rawData.Set("replaces_price_id", value); } } - /// - /// The definition of a new allocation price to create and add to the subscription. - /// - public NewAllocationPrice? AllocationPrice + public string? ReferenceID { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); + 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 + ); } - init { this._rawData.Set("allocation_price", value); } } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. - /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); - } + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; } - /// - /// The external price id of the price to add to the subscription. - /// - public string? ExternalPriceID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPrice 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( + NewSubscriptionBulkPrice 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( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters 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( + NewSubscriptionPackagePrice 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( + NewSubscriptionMatrixPrice 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( + NewSubscriptionThresholdTotalAmountPrice 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( + NewSubscriptionTieredPackagePrice 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( + NewSubscriptionTieredWithMinimumPrice value, + JsonElement? element = null ) - : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } + { + this.Value = value; + this._element = element; + } - public SubscriptionSchedulePlanChangeParamsReplacePrice( - IReadOnlyDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPrice value, + JsonElement? element = null ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice 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( + NewSubscriptionPackageWithAllocationPrice value, + JsonElement? element = null ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) - : this() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithPercentPrice value, + JsonElement? element = null + ) { - this.ReplacesPriceID = replacesPriceID; + this.Value = value; + this._element = element; } -} -class SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePrice.FromRawUnchecked(rawData); -} + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } -/// -/// New subscription price request body params. -/// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter))] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - JsonElement? _element = null; + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public JsonElement Json + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedAllocationPrice 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( + NewSubscriptionBulkWithProrationPrice 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( + NewSubscriptionGroupedWithProratedMinimumPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice value, + JsonElement? element = null + ) { - 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.Value = value; + this._element = element; } - public double? ConversionRate + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value, + JsonElement? element = null + ) { - 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 - ); - } + this.Value = value; + this._element = element; } - public string? Currency + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value, + JsonElement? element = null + ) { - 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 - ); - } + this.Value = value; + this._element = element; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value, + JsonElement? element = 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, - minimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + this.Value = value; + this._element = element; } - public string? ExternalPriceID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice value, + JsonElement? element = 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, - minimum: (x) => x.ExternalPriceID, - newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + this.Value = value; + this._element = element; } - public double? FixedPriceQuantity + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value, + JsonElement? element = 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, - minimum: (x) => x.FixedPriceQuantity, - newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } + this.Value = value; + this._element = element; } - public string? InvoiceGroupingKey + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = 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, - minimum: (x) => x.InvoiceGroupingKey, - newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } + this.Value = value; + this._element = element; } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMinimumCompositePrice value, + JsonElement? element = 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, - 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; + this.Value = value; + this._element = element; } public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPrice value, + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value, JsonElement? element = null ) { @@ -12222,7 +11570,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePrice( } public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkPrice value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value, JsonElement? element = null ) { @@ -12230,601 +11578,340 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePrice( this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value, - JsonElement? element = null - ) + public SubscriptionSchedulePlanChangeParamsReplacePricePrice(JsonElement element) { - this.Value = value; this._element = element; } - 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.TryPickNewSubscriptionUnit(out var value)) { + /// // `value` is of type `NewSubscriptionUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionUnitPrice; + 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.TryPickNewSubscriptionTiered(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTiered( + [NotNullWhen(true)] out NewSubscriptionTieredPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredPrice; + 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.TryPickNewSubscriptionBulk(out var value)) { + /// // `value` is of type `NewSubscriptionBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionBulkPrice; + 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value ) { - this.Value = value; - this._element = element; + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; + 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.TryPickNewSubscriptionPackage(out var value)) { + /// // `value` is of type `NewSubscriptionPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionPackage( + [NotNullWhen(true)] out NewSubscriptionPackagePrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionPackagePrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice 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.TryPickNewSubscriptionMatrix(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrix( + [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionMatrixPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice 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; - } - - 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 NewSubscriptionTieredPackagePrice; + 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + public bool TryPickNewSubscriptionTieredWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + ) { - value = this.Value as NewSubscriptionUnitPrice; + value = this.Value as NewSubscriptionTieredWithMinimumPrice; 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.TryPickNewSubscriptionGroupedTiered(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + public bool TryPickNewSubscriptionGroupedTiered( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value ) { - value = this.Value as NewSubscriptionTieredPrice; + value = this.Value as NewSubscriptionGroupedTieredPrice; 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.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + public bool TryPickNewSubscriptionTieredPackageWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + ) { - value = this.Value as NewSubscriptionBulkPrice; + value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; 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.TryPickNewSubscriptionPackageWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value + public bool TryPickNewSubscriptionPackageWithAllocation( + [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value ) { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; + value = this.Value as NewSubscriptionPackageWithAllocationPrice; 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.TryPickNewSubscriptionUnitWithPercent(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value + public bool TryPickNewSubscriptionUnitWithPercent( + [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value ) { - value = this.Value as NewSubscriptionPackagePrice; + value = this.Value as NewSubscriptionUnitWithPercentPrice; 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.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + public bool TryPickNewSubscriptionMatrixWithAllocation( + [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value ) { - value = this.Value as NewSubscriptionMatrixPrice; + 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.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value - ) - { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; - 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.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value - ) - { - value = this.Value as NewSubscriptionTieredPackagePrice; - 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value - ) - { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; - 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.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value - ) - { - value = this.Value as NewSubscriptionGroupedTieredPrice; - 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.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value - ) - { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; - 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.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value - ) - { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; - 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.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value - ) - { - value = this.Value as NewSubscriptionUnitWithPercentPrice; - 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.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 . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` /// Console.WriteLine(value); /// } /// @@ -13145,29 +12232,6 @@ out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAlloca 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 `SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -13280,7 +12344,6 @@ out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} @@ -13317,7 +12380,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 @@ -13409,9 +12471,6 @@ public void Switch( case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; @@ -13471,7 +12530,6 @@ public void Switch( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} @@ -13556,7 +12614,6 @@ public T Match( SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func< @@ -13618,7 +12675,6 @@ public T Match( ), SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value => minimum(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value => percent(value), SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value => eventOutput( @@ -13742,10 +12798,6 @@ public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePrice SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value - ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( NewSubscriptionMinimumCompositePrice value ) => new(value); @@ -13814,7 +12866,6 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() @@ -14479,1108 +13530,55 @@ JsonSerializerOptions options { var deserialized = JsonSerializer.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 - { - 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 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 - { - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() - { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - string unitAmount - ) - : this() - { - this.UnitAmount = unitAmount; - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - 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(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig - : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } - - /// - /// 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" - ), - }; - } - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? 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); -} + 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(); @@ -15595,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(); @@ -15619,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 @@ -15659,7 +13671,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > >("cadence"); } @@ -15705,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. /// @@ -15779,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" ); } @@ -15913,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(); @@ -15941,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 ) { @@ -15970,8 +13967,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15979,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 ) { @@ -16128,7 +14165,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -16136,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 ) { @@ -16230,7 +14258,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -16238,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; @@ -16280,7 +14391,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16289,7 +14400,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16298,7 +14409,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( JsonElement element ) { @@ -16382,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" ); } } @@ -16418,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); @@ -16446,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); @@ -16468,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 @@ -16536,7 +14647,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( element ); } @@ -16545,7 +14656,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -16555,11 +14666,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration : JsonModel { /// @@ -16567,7 +14678,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > Cadence { get @@ -16576,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. /// @@ -16637,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. /// @@ -16696,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" ); } @@ -16831,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(); @@ -16858,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 ) { @@ -16887,8 +14998,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16896,14 +15007,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration.FromRawUnchecked( rawData ); } @@ -16912,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, @@ -16924,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 @@ -16936,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 ) { @@ -17077,7 +15258,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -17085,8 +15266,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17094,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; @@ -17127,7 +15308,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17136,7 +15317,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17145,7 +15326,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( JsonElement element ) { @@ -17229,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" ); } } @@ -17265,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); @@ -17293,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); @@ -17315,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 @@ -17383,7 +15564,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( element ); } @@ -17392,7 +15573,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17402,11 +15583,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// @@ -17414,7 +15595,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > Cadence { get @@ -17423,7 +15604,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >("cadence"); } @@ -17431,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); } } /// @@ -17543,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" ); } @@ -17678,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") ) ) { @@ -17705,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 ) { @@ -17734,8 +15915,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17743,14 +15924,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( rawData ); } @@ -17759,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, @@ -17771,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 @@ -17783,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 ), }; @@ -17803,7 +15984,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -17811,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)) @@ -17833,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 ) { @@ -17924,7 +16105,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -17932,8 +16113,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17941,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; @@ -17974,7 +16155,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17983,7 +16164,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17992,7 +16173,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( JsonElement element ) { @@ -18076,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" ); } } @@ -18112,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); @@ -18140,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); @@ -18162,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 @@ -18230,7 +16411,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -18239,7 +16420,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -18249,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); } } /// @@ -18386,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" ); } @@ -18521,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"); } @@ -18543,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 ) { @@ -18572,8 +16762,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18581,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, @@ -18606,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 @@ -18617,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 ) { @@ -18641,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)) @@ -18663,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 ) { @@ -18731,7 +16952,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -18739,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; @@ -18790,7 +17002,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -18799,7 +17011,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18808,7 +17020,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( JsonElement element ) { @@ -18892,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" ); } } @@ -18928,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); @@ -18956,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); @@ -18978,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 @@ -19046,7 +17258,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -19055,7 +17267,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { From 2bc3e436b724ff58d3191ea1c4632be595a9e5f5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 18:14:29 +0000 Subject: [PATCH 06/39] chore(internal): codegen related update --- .../Invoices/InvoiceCreateParamsTest.cs | 151 +++++++++--------- .../Invoices/InvoiceListSummaryParamsTest.cs | 100 ++---------- src/Orb/Core/ModelBase.cs | 1 - .../Invoices/InvoiceListSummaryParams.cs | 76 +-------- 4 files changed, 96 insertions(+), 232 deletions(-) diff --git a/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs index 14a974edf..8cca91c82 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", @@ -333,7 +333,7 @@ public void Url_Works() [Fact] public void CopyConstructor_Works() { - var parameters = new Invoices::InvoiceCreateParams + var parameters = new InvoiceCreateParams { Currency = "USD", InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -343,7 +343,7 @@ public void CopyConstructor_Works() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -351,17 +351,17 @@ public void CopyConstructor_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"], }, ], @@ -375,7 +375,7 @@ public void CopyConstructor_Works() WillAutoIssue = false, }; - Invoices::InvoiceCreateParams copied = new(parameters); + InvoiceCreateParams copied = new(parameters); Assert.Equal(parameters, copied); } @@ -386,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", @@ -399,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); @@ -417,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", @@ -429,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); } @@ -440,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", @@ -452,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 ); @@ -460,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); @@ -478,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", @@ -496,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 ); @@ -517,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 ); @@ -535,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 ); @@ -554,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 ); @@ -581,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/InvoiceListSummaryParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs index 3b73526a7..38f487e10 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", }; @@ -321,8 +312,7 @@ public void CopyConstructor_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", }; @@ -449,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/Core/ModelBase.cs b/src/Orb/Core/ModelBase.cs index d74ae4e8a..cf069d55d 100644 --- a/src/Orb/Core/ModelBase.cs +++ b/src/Orb/Core/ModelBase.cs @@ -579,7 +579,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs index 19b21e236..e62a3533c 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs @@ -231,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)); } } @@ -452,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 - ); - } -} From d8f27e8e10dc99f7d6e51186171181a05a59547d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 Jan 2026 02:25:00 +0000 Subject: [PATCH 07/39] feat(api): api update --- .stats.yml | 4 ++-- .../Credits/Ledger/LedgerListByExternalIDParams.cs | 7 ++----- .../Customers/Credits/Ledger/LedgerListParams.cs | 7 ++----- src/Orb/Services/Customers/Credits/ILedgerService.cs | 12 ++++-------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index 666bff36b..1f41e32fa 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-c131de17773b450eb1ec03ca001f94d3777e35347234869a7efee083003e1513.yml -openapi_spec_hash: 5d2d4a3a9ada1c381efb318b6897994d +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/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs index 8cec3cb17..b53d970c1 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 diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs index 804b7d886..25e99de75 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 diff --git a/src/Orb/Services/Customers/Credits/ILedgerService.cs b/src/Orb/Services/Customers/Credits/ILedgerService.cs index 11adc9dec..bc36776d6 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 From 9c7927a2079895ffcd40cc12611748f7b61bad02 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 15:00:40 +0000 Subject: [PATCH 08/39] chore(internal): add copy constructor tests --- src/Orb.Tests/Models/AddressTest.cs | 18 + .../Models/AdjustmentIntervalTest.cs | 36 + src/Orb.Tests/Models/AggregatedCostTest.cs | 140 + .../Alerts/AlertListPageResponseTest.cs | 36 + src/Orb.Tests/Models/Alerts/AlertTest.cs | 65 + src/Orb.Tests/Models/Alerts/ThresholdTest.cs | 10 + src/Orb.Tests/Models/AllocationTest.cs | 43 + .../Models/AmountDiscountIntervalTest.cs | 41 + src/Orb.Tests/Models/AmountDiscountTest.cs | 40 + .../Beta/BetaCreatePlanVersionParamsTest.cs | 1146 +++- ...ternalPlanIDCreatePlanVersionParamsTest.cs | 1146 +++- .../Models/Beta/PlanVersionPhaseTest.cs | 18 + src/Orb.Tests/Models/Beta/PlanVersionTest.cs | 168 + .../Models/BillableMetricTinyTest.cs | 10 + .../BillingCycleAnchorConfigurationTest.cs | 15 + .../Models/BillingCycleConfigurationTest.cs | 10 + src/Orb.Tests/Models/BulkConfigTest.cs | 13 + src/Orb.Tests/Models/BulkTierTest.cs | 10 + .../ChangedSubscriptionResourcesTest.cs | 4061 ++++++++---- .../Models/ConversionRateTierTest.cs | 15 + .../Models/ConversionRateTieredConfigTest.cs | 21 + .../Models/ConversionRateUnitConfigTest.cs | 10 + src/Orb.Tests/Models/CouponRedemptionTest.cs | 15 + .../Models/Coupons/CouponCreateParamsTest.cs | 20 + .../Coupons/CouponListPageResponseTest.cs | 41 + src/Orb.Tests/Models/Coupons/CouponTest.cs | 34 + .../CreditBlockRetrieveResponseTest.cs | 43 + src/Orb.Tests/Models/CreditNoteTinyTest.cs | 10 + .../CreditNotes/CreditNoteCreateParamsTest.cs | 16 + .../CreditNoteListPageResponseTest.cs | 87 + src/Orb.Tests/Models/CustomExpirationTest.cs | 14 + src/Orb.Tests/Models/CustomerMinifiedTest.cs | 10 + src/Orb.Tests/Models/CustomerTaxIDTest.cs | 15 + .../Customers/AccountingProviderConfigTest.cs | 14 + .../Models/Customers/AddressInputTest.cs | 18 + .../BalanceTransactionCreateResponseTest.cs | 22 + .../BalanceTransactionListPageResponseTest.cs | 29 + .../BalanceTransactionListResponseTest.cs | 22 + .../Costs/CostListByExternalIDResponseTest.cs | 146 + .../Customers/Costs/CostListResponseTest.cs | 146 + .../CreditListByExternalIDPageResponseTest.cs | 35 + .../CreditListByExternalIDResponseTest.cs | 43 + .../Credits/CreditListPageResponseTest.cs | 35 + .../Credits/CreditListResponseTest.cs | 43 + .../Credits/Ledger/AffectedBlockTest.cs | 39 + .../Ledger/AmendmentLedgerEntryTest.cs | 39 + .../CreditBlockExpiryLedgerEntryTest.cs | 39 + .../Ledger/DecrementLedgerEntryTest.cs | 42 + .../Ledger/ExpirationChangeLedgerEntryTest.cs | 40 + .../Ledger/IncrementLedgerEntryTest.cs | 381 ++ ...LedgerCreateEntryByExternalIDParamsTest.cs | 143 + .../Ledger/LedgerCreateEntryParamsTest.cs | 142 + .../LedgerListByExternalIDPageResponseTest.cs | 416 ++ .../Ledger/LedgerListPageResponseTest.cs | 416 ++ .../Ledger/VoidInitiatedLedgerEntryTest.cs | 42 + .../Credits/Ledger/VoidLedgerEntryTest.cs | 41 + .../TopUpCreateByExternalIDParamsTest.cs | 16 + .../TopUpCreateByExternalIDResponseTest.cs | 26 + .../Credits/TopUps/TopUpCreateParamsTest.cs | 16 + .../Credits/TopUps/TopUpCreateResponseTest.cs | 26 + .../TopUps/TopUpInvoiceSettingsTest.cs | 16 + .../TopUpListByExternalIDPageResponseTest.cs | 33 + .../TopUpListByExternalIDResponseTest.cs | 26 + .../TopUps/TopUpListPageResponseTest.cs | 33 + .../Credits/TopUps/TopUpListResponseTest.cs | 26 + .../Customers/CustomerCreateParamsTest.cs | 64 + .../Customers/CustomerHierarchyConfigTest.cs | 14 + .../Customers/CustomerListPageResponseTest.cs | 94 + .../Models/Customers/CustomerTest.cs | 177 + .../CustomerUpdateByExternalIDParamsTest.cs | 78 + .../Customers/CustomerUpdateParamsTest.cs | 78 + .../NewAccountingSyncConfigurationTest.cs | 21 + .../NewAvalaraTaxConfigurationTest.cs | 16 + .../NewReportingConfigurationTest.cs | 10 + .../Customers/NewSphereConfigurationTest.cs | 15 + .../Customers/NewTaxJarConfigurationTest.cs | 15 + .../DimensionalPriceConfigurationTest.cs | 14 + ...nalPriceGroupDimensionalPriceGroupsTest.cs | 25 + .../DimensionalPriceGroupTest.cs | 18 + .../Backfills/BackfillCloseResponseTest.cs | 23 + .../Backfills/BackfillCreateResponseTest.cs | 23 + .../Backfills/BackfillFetchResponseTest.cs | 23 + .../Backfills/BackfillListPageResponseTest.cs | 30 + .../Backfills/BackfillListResponseTest.cs | 23 + .../Backfills/BackfillRevertResponseTest.cs | 23 + .../Events/EventDeprecateResponseTest.cs | 10 + .../Models/Events/EventIngestParamsTest.cs | 21 + .../Models/Events/EventIngestResponseTest.cs | 41 + .../Models/Events/EventSearchResponseTest.cs | 50 + .../Models/Events/EventUpdateResponseTest.cs | 10 + .../Models/Events/Volume/EventVolumesTest.cs | 36 + .../FixedFeeQuantityScheduleEntryTest.cs | 16 + .../Models/FixedFeeQuantityTransitionTest.cs | 15 + .../InvoiceLineItemCreateResponseTest.cs | 186 + src/Orb.Tests/Models/InvoiceTest.cs | 598 ++ src/Orb.Tests/Models/InvoiceTinyTest.cs | 10 + .../Invoices/InvoiceCreateParamsTest.cs | 19 + .../InvoiceFetchUpcomingResponseTest.cs | 598 ++ .../Invoices/InvoiceListPageResponseTest.cs | 352 + .../InvoiceListSummaryPageResponseTest.cs | 123 + .../InvoiceListSummaryResponseTest.cs | 190 + src/Orb.Tests/Models/ItemSlimTest.cs | 10 + .../Models/Items/ItemListPageResponseTest.cs | 33 + src/Orb.Tests/Models/Items/ItemTest.cs | 39 + .../Models/Items/ItemUpdateParamsTest.cs | 14 + src/Orb.Tests/Models/MatrixConfigTest.cs | 15 + src/Orb.Tests/Models/MatrixSubLineItemTest.cs | 19 + src/Orb.Tests/Models/MatrixValueTest.cs | 10 + .../Models/MatrixWithAllocationConfigTest.cs | 30 + src/Orb.Tests/Models/MaximumIntervalTest.cs | 40 + src/Orb.Tests/Models/MaximumTest.cs | 38 + .../Models/Metrics/BillableMetricTest.cs | 34 + .../Metrics/MetricListPageResponseTest.cs | 41 + src/Orb.Tests/Models/MinimumIntervalTest.cs | 40 + src/Orb.Tests/Models/MinimumTest.cs | 38 + .../MonetaryAmountDiscountAdjustmentTest.cs | 44 + .../Models/MonetaryMaximumAdjustmentTest.cs | 44 + .../Models/MonetaryMinimumAdjustmentTest.cs | 45 + ...onetaryPercentageDiscountAdjustmentTest.cs | 44 + .../MonetaryUsageDiscountAdjustmentTest.cs | 44 + .../Models/NewAllocationPriceTest.cs | 47 + src/Orb.Tests/Models/NewAmountDiscountTest.cs | 44 + .../NewBillingCycleConfigurationTest.cs | 14 + .../NewDimensionalPriceConfigurationTest.cs | 15 + .../Models/NewFloatingBulkPriceTest.cs | 46 + .../NewFloatingBulkWithProrationPriceTest.cs | 78 + ...wFloatingCumulativeGroupedBulkPriceTest.cs | 95 + .../NewFloatingGroupedAllocationPriceTest.cs | 66 + ...ewFloatingGroupedTieredPackagePriceTest.cs | 88 + .../NewFloatingGroupedTieredPriceTest.cs | 86 + ...atingGroupedWithMeteredMinimumPriceTest.cs | 113 + ...tingGroupedWithProratedMinimumPriceTest.cs | 67 + .../Models/NewFloatingMatrixPriceTest.cs | 51 + ...ewFloatingMatrixWithAllocationPriceTest.cs | 52 + ...wFloatingMatrixWithDisplayNamePriceTest.cs | 95 + ...wFloatingMaxGroupTieredPackagePriceTest.cs | 88 + .../NewFloatingMinimumCompositePriceTest.cs | 60 + .../Models/NewFloatingPackagePriceTest.cs | 46 + ...wFloatingPackageWithAllocationPriceTest.cs | 66 + ...calableMatrixWithTieredPricingPriceTest.cs | 122 + ...gScalableMatrixWithUnitPricingPriceTest.cs | 102 + ...ewFloatingThresholdTotalAmountPriceTest.cs | 82 + .../NewFloatingTieredPackagePriceTest.cs | 86 + ...oatingTieredPackageWithMinimumPriceTest.cs | 107 + .../Models/NewFloatingTieredPriceTest.cs | 58 + .../NewFloatingTieredWithMinimumPriceTest.cs | 109 + ...NewFloatingTieredWithProrationPriceTest.cs | 75 + .../Models/NewFloatingUnitPriceTest.cs | 46 + .../NewFloatingUnitWithPercentPriceTest.cs | 56 + .../NewFloatingUnitWithProrationPriceTest.cs | 56 + src/Orb.Tests/Models/NewMaximumTest.cs | 44 + src/Orb.Tests/Models/NewMinimumTest.cs | 45 + .../Models/NewPercentageDiscountTest.cs | 44 + src/Orb.Tests/Models/NewPlanBulkPriceTest.cs | 47 + .../NewPlanBulkWithProrationPriceTest.cs | 83 + .../NewPlanCumulativeGroupedBulkPriceTest.cs | 98 + .../NewPlanGroupedAllocationPriceTest.cs | 67 + .../NewPlanGroupedTieredPackagePriceTest.cs | 89 + .../Models/NewPlanGroupedTieredPriceTest.cs | 87 + ...wPlanGroupedWithMeteredMinimumPriceTest.cs | 115 + ...PlanGroupedWithProratedMinimumPriceTest.cs | 67 + .../Models/NewPlanMatrixPriceTest.cs | 52 + .../NewPlanMatrixWithAllocationPriceTest.cs | 53 + .../NewPlanMatrixWithDisplayNamePriceTest.cs | 96 + .../NewPlanMaxGroupTieredPackagePriceTest.cs | 89 + .../NewPlanMinimumCompositePriceTest.cs | 61 + .../Models/NewPlanPackagePriceTest.cs | 47 + .../NewPlanPackageWithAllocationPriceTest.cs | 67 + ...calableMatrixWithTieredPricingPriceTest.cs | 129 + ...nScalableMatrixWithUnitPricingPriceTest.cs | 107 + .../NewPlanThresholdTotalAmountPriceTest.cs | 89 + .../Models/NewPlanTieredPackagePriceTest.cs | 87 + ...ewPlanTieredPackageWithMinimumPriceTest.cs | 108 + .../Models/NewPlanTieredPriceTest.cs | 59 + .../NewPlanTieredWithMinimumPriceTest.cs | 110 + src/Orb.Tests/Models/NewPlanUnitPriceTest.cs | 47 + .../Models/NewPlanUnitWithPercentPriceTest.cs | 61 + .../NewPlanUnitWithProrationPriceTest.cs | 60 + src/Orb.Tests/Models/NewUsageDiscountTest.cs | 44 + src/Orb.Tests/Models/OtherSubLineItemTest.cs | 17 + src/Orb.Tests/Models/PackageConfigTest.cs | 10 + .../Models/PaginationMetadataTest.cs | 10 + src/Orb.Tests/Models/PerPriceCostTest.cs | 125 + .../Models/PercentageDiscountIntervalTest.cs | 41 + .../Models/PercentageDiscountTest.cs | 40 + .../PlanPhaseAmountDiscountAdjustmentTest.cs | 44 + .../Models/PlanPhaseMaximumAdjustmentTest.cs | 44 + .../Models/PlanPhaseMinimumAdjustmentTest.cs | 45 + ...anPhasePercentageDiscountAdjustmentTest.cs | 44 + .../PlanPhaseUsageDiscountAdjustmentTest.cs | 44 + .../Migrations/MigrationCancelResponseTest.cs | 16 + .../MigrationListPageResponseTest.cs | 23 + .../Migrations/MigrationListResponseTest.cs | 16 + .../MigrationRetrieveResponseTest.cs | 16 + .../Models/Plans/PlanCreateParamsTest.cs | 607 +- .../Models/Plans/PlanListPageResponseTest.cs | 294 + src/Orb.Tests/Models/Plans/PlanTest.cs | 388 ++ src/Orb.Tests/Models/PriceIntervalTest.cs | 139 + src/Orb.Tests/Models/PriceTest.cs | 5850 +++++++++++++++-- .../Models/Prices/EvaluatePriceGroupTest.cs | 15 + .../Models/Prices/PriceCreateParamsTest.cs | 345 + .../Prices/PriceEvaluateMultipleParamsTest.cs | 407 ++ .../PriceEvaluateMultipleResponseTest.cs | 56 + .../PriceEvaluatePreviewEventsParamsTest.cs | 450 ++ .../PriceEvaluatePreviewEventsResponseTest.cs | 56 + .../Prices/PriceEvaluateResponseTest.cs | 21 + .../Prices/PriceListPageResponseTest.cs | 130 + src/Orb.Tests/Models/SharedCreditNoteTest.cs | 195 + src/Orb.Tests/Models/SharedTierTest.cs | 15 + .../SharedTieredConversionRateConfigTest.cs | 23 + .../SharedUnitConversionRateConfigTest.cs | 14 + .../Models/SubLineItemGroupingTest.cs | 10 + .../Models/SubLineItemMatrixConfigTest.cs | 10 + .../Models/SubscriptionChangeMinifiedTest.cs | 10 + .../MutatedSubscriptionTest.cs | 1507 +++++ .../SubscriptionChangeApplyResponseTest.cs | 1564 +++++ .../SubscriptionChangeCancelResponseTest.cs | 1564 +++++ .../SubscriptionChangeListPageResponseTest.cs | 25 + .../SubscriptionChangeListResponseTest.cs | 18 + .../SubscriptionChangeRetrieveResponseTest.cs | 1564 +++++ .../Models/SubscriptionMinifiedTest.cs | 10 + .../Models/SubscriptionTrialInfoTest.cs | 13 + .../Subscriptions/DiscountOverrideTest.cs | 16 + .../NewSubscriptionBulkPriceTest.cs | 47 + ...wSubscriptionBulkWithProrationPriceTest.cs | 84 + ...scriptionCumulativeGroupedBulkPriceTest.cs | 97 + ...wSubscriptionGroupedAllocationPriceTest.cs | 68 + ...bscriptionGroupedTieredPackagePriceTest.cs | 90 + .../NewSubscriptionGroupedTieredPriceTest.cs | 87 + ...ptionGroupedWithMeteredMinimumPriceTest.cs | 114 + ...tionGroupedWithProratedMinimumPriceTest.cs | 68 + .../NewSubscriptionMatrixPriceTest.cs | 52 + ...bscriptionMatrixWithAllocationPriceTest.cs | 53 + ...scriptionMatrixWithDisplayNamePriceTest.cs | 97 + ...scriptionMaxGroupTieredPackagePriceTest.cs | 90 + ...ewSubscriptionMinimumCompositePriceTest.cs | 62 + .../NewSubscriptionPackagePriceTest.cs | 47 + ...scriptionPackageWithAllocationPriceTest.cs | 68 + ...calableMatrixWithTieredPricingPriceTest.cs | 124 + ...nScalableMatrixWithUnitPricingPriceTest.cs | 104 + ...bscriptionThresholdTotalAmountPriceTest.cs | 88 + .../NewSubscriptionTieredPackagePriceTest.cs | 87 + ...iptionTieredPackageWithMinimumPriceTest.cs | 109 + .../NewSubscriptionTieredPriceTest.cs | 59 + ...wSubscriptionTieredWithMinimumPriceTest.cs | 111 + .../NewSubscriptionUnitPriceTest.cs | 47 + ...NewSubscriptionUnitWithPercentPriceTest.cs | 61 + ...wSubscriptionUnitWithProrationPriceTest.cs | 58 + .../SubscriptionCreateParamsTest.cs | 1169 +++- .../SubscriptionFetchCostsResponseTest.cs | 146 + ...bscriptionFetchSchedulePageResponseTest.cs | 28 + .../SubscriptionFetchScheduleResponseTest.cs | 36 + .../SubscriptionPriceIntervalsParamsTest.cs | 662 +- ...ubscriptionSchedulePlanChangeParamsTest.cs | 1394 +++- .../SubscriptionSubscriptionsTest.cs | 655 ++ .../Models/Subscriptions/SubscriptionTest.cs | 633 ++ .../Subscriptions/SubscriptionUsageTest.cs | 175 + src/Orb.Tests/Models/TaxAmountTest.cs | 15 + src/Orb.Tests/Models/TierSubLineItemTest.cs | 38 + src/Orb.Tests/Models/TieredConfigTest.cs | 22 + .../TopLevel/TopLevelPingResponseTest.cs | 10 + src/Orb.Tests/Models/TrialDiscountTest.cs | 41 + src/Orb.Tests/Models/UnitConfigTest.cs | 10 + .../Models/UsageDiscountIntervalTest.cs | 41 + src/Orb.Tests/Models/UsageDiscountTest.cs | 40 + src/Orb/Models/Address.cs | 3 + src/Orb/Models/AdjustmentInterval.cs | 3 + src/Orb/Models/AggregatedCost.cs | 3 + src/Orb/Models/Alerts/Alert.cs | 12 + .../Models/Alerts/AlertListPageResponse.cs | 3 + src/Orb/Models/Alerts/Threshold.cs | 3 + src/Orb/Models/Allocation.cs | 6 + src/Orb/Models/AmountDiscount.cs | 6 + src/Orb/Models/AmountDiscountInterval.cs | 6 + .../Beta/BetaCreatePlanVersionParams.cs | 108 + .../ExternalPlanIDCreatePlanVersionParams.cs | 108 + src/Orb/Models/Beta/PlanVersion.cs | 3 + src/Orb/Models/Beta/PlanVersionPhase.cs | 3 + src/Orb/Models/BillableMetricTiny.cs | 3 + .../Models/BillingCycleAnchorConfiguration.cs | 3 + src/Orb/Models/BillingCycleConfiguration.cs | 3 + src/Orb/Models/BulkConfig.cs | 3 + src/Orb/Models/BulkTier.cs | 3 + .../Models/ChangedSubscriptionResources.cs | 21 + src/Orb/Models/ConversionRateTier.cs | 3 + src/Orb/Models/ConversionRateTieredConfig.cs | 3 + src/Orb/Models/ConversionRateUnitConfig.cs | 3 + src/Orb/Models/CouponRedemption.cs | 3 + src/Orb/Models/Coupons/Coupon.cs | 3 + src/Orb/Models/Coupons/CouponCreateParams.cs | 6 + .../Models/Coupons/CouponListPageResponse.cs | 3 + .../CreditBlockRetrieveResponse.cs | 6 + src/Orb/Models/CreditNoteTiny.cs | 3 + .../CreditNotes/CreditNoteCreateParams.cs | 3 + .../CreditNotes/CreditNoteListPageResponse.cs | 3 + src/Orb/Models/CustomExpiration.cs | 3 + src/Orb/Models/CustomerMinified.cs | 3 + src/Orb/Models/CustomerTaxID.cs | 3 + .../Customers/AccountingProviderConfig.cs | 3 + src/Orb/Models/Customers/AddressInput.cs | 3 + .../BalanceTransactionCreateResponse.cs | 3 + .../BalanceTransactionListPageResponse.cs | 3 + .../BalanceTransactionListResponse.cs | 3 + .../Costs/CostListByExternalIDResponse.cs | 3 + .../Customers/Costs/CostListResponse.cs | 3 + .../CreditListByExternalIDPageResponse.cs | 3 + .../Credits/CreditListByExternalIDResponse.cs | 6 + .../Credits/CreditListPageResponse.cs | 3 + .../Customers/Credits/CreditListResponse.cs | 6 + .../Customers/Credits/Ledger/AffectedBlock.cs | 6 + .../Credits/Ledger/AmendmentLedgerEntry.cs | 3 + .../Ledger/CreditBlockExpiryLedgerEntry.cs | 3 + .../Credits/Ledger/DecrementLedgerEntry.cs | 3 + .../Ledger/ExpirationChangeLedgerEntry.cs | 3 + .../Credits/Ledger/IncrementLedgerEntry.cs | 3 + .../LedgerCreateEntryByExternalIDParams.cs | 21 + .../Credits/Ledger/LedgerCreateEntryParams.cs | 21 + .../LedgerListByExternalIDPageResponse.cs | 3 + .../Credits/Ledger/LedgerListPageResponse.cs | 3 + .../Ledger/VoidInitiatedLedgerEntry.cs | 3 + .../Credits/Ledger/VoidLedgerEntry.cs | 3 + .../TopUps/TopUpCreateByExternalIDParams.cs | 3 + .../TopUps/TopUpCreateByExternalIDResponse.cs | 3 + .../Credits/TopUps/TopUpCreateParams.cs | 3 + .../Credits/TopUps/TopUpCreateResponse.cs | 3 + .../Credits/TopUps/TopUpInvoiceSettings.cs | 3 + .../TopUpListByExternalIDPageResponse.cs | 3 + .../TopUps/TopUpListByExternalIDResponse.cs | 3 + .../Credits/TopUps/TopUpListPageResponse.cs | 3 + .../Credits/TopUps/TopUpListResponse.cs | 3 + src/Orb/Models/Customers/Customer.cs | 21 + .../Models/Customers/CustomerCreateParams.cs | 15 + .../Customers/CustomerHierarchyConfig.cs | 3 + .../Customers/CustomerListPageResponse.cs | 3 + .../CustomerUpdateByExternalIDParams.cs | 15 + .../Models/Customers/CustomerUpdateParams.cs | 15 + .../NewAccountingSyncConfiguration.cs | 3 + .../Customers/NewAvalaraTaxConfiguration.cs | 3 + .../Customers/NewReportingConfiguration.cs | 3 + .../Customers/NewSphereConfiguration.cs | 3 + .../Customers/NewTaxJarConfiguration.cs | 3 + .../Models/DimensionalPriceConfiguration.cs | 3 + .../DimensionalPriceGroup.cs | 3 + ...nsionalPriceGroupDimensionalPriceGroups.cs | 3 + .../Events/Backfills/BackfillCloseResponse.cs | 3 + .../Backfills/BackfillCreateResponse.cs | 3 + .../Events/Backfills/BackfillFetchResponse.cs | 3 + .../Backfills/BackfillListPageResponse.cs | 3 + .../Events/Backfills/BackfillListResponse.cs | 3 + .../Backfills/BackfillRevertResponse.cs | 3 + .../Models/Events/EventDeprecateResponse.cs | 3 + src/Orb/Models/Events/EventIngestParams.cs | 3 + src/Orb/Models/Events/EventIngestResponse.cs | 9 + src/Orb/Models/Events/EventSearchResponse.cs | 6 + src/Orb/Models/Events/EventUpdateResponse.cs | 3 + src/Orb/Models/Events/Volume/EventVolumes.cs | 6 + .../Models/FixedFeeQuantityScheduleEntry.cs | 3 + src/Orb/Models/FixedFeeQuantityTransition.cs | 3 + src/Orb/Models/Invoice.cs | 18 + .../InvoiceLineItemCreateResponse.cs | 3 + src/Orb/Models/InvoiceTiny.cs | 3 + .../Models/Invoices/InvoiceCreateParams.cs | 3 + .../Invoices/InvoiceFetchUpcomingResponse.cs | 18 + .../Invoices/InvoiceListPageResponse.cs | 3 + .../InvoiceListSummaryPageResponse.cs | 3 + .../Invoices/InvoiceListSummaryResponse.cs | 15 + src/Orb/Models/ItemSlim.cs | 3 + src/Orb/Models/Items/Item.cs | 6 + src/Orb/Models/Items/ItemListPageResponse.cs | 3 + src/Orb/Models/Items/ItemUpdateParams.cs | 3 + src/Orb/Models/MatrixConfig.cs | 3 + src/Orb/Models/MatrixSubLineItem.cs | 3 + src/Orb/Models/MatrixValue.cs | 3 + src/Orb/Models/MatrixWithAllocationConfig.cs | 6 + src/Orb/Models/Maximum.cs | 6 + src/Orb/Models/MaximumInterval.cs | 6 + src/Orb/Models/Metrics/BillableMetric.cs | 3 + .../Models/Metrics/MetricListPageResponse.cs | 3 + src/Orb/Models/Minimum.cs | 6 + src/Orb/Models/MinimumInterval.cs | 6 + .../MonetaryAmountDiscountAdjustment.cs | 6 + src/Orb/Models/MonetaryMaximumAdjustment.cs | 6 + src/Orb/Models/MonetaryMinimumAdjustment.cs | 6 + .../MonetaryPercentageDiscountAdjustment.cs | 6 + .../Models/MonetaryUsageDiscountAdjustment.cs | 6 + src/Orb/Models/NewAllocationPrice.cs | 6 + src/Orb/Models/NewAmountDiscount.cs | 6 + .../Models/NewBillingCycleConfiguration.cs | 3 + .../NewDimensionalPriceConfiguration.cs | 3 + src/Orb/Models/NewFloatingBulkPrice.cs | 3 + .../NewFloatingBulkWithProrationPrice.cs | 9 + .../NewFloatingCumulativeGroupedBulkPrice.cs | 9 + .../NewFloatingGroupedAllocationPrice.cs | 6 + .../NewFloatingGroupedTieredPackagePrice.cs | 9 + .../Models/NewFloatingGroupedTieredPrice.cs | 9 + ...wFloatingGroupedWithMeteredMinimumPrice.cs | 12 + ...FloatingGroupedWithProratedMinimumPrice.cs | 6 + src/Orb/Models/NewFloatingMatrixPrice.cs | 3 + .../NewFloatingMatrixWithAllocationPrice.cs | 3 + .../NewFloatingMatrixWithDisplayNamePrice.cs | 9 + .../NewFloatingMaxGroupTieredPackagePrice.cs | 9 + .../NewFloatingMinimumCompositePrice.cs | 6 + src/Orb/Models/NewFloatingPackagePrice.cs | 3 + .../NewFloatingPackageWithAllocationPrice.cs | 6 + ...ingScalableMatrixWithTieredPricingPrice.cs | 12 + ...atingScalableMatrixWithUnitPricingPrice.cs | 9 + .../NewFloatingThresholdTotalAmountPrice.cs | 9 + .../Models/NewFloatingTieredPackagePrice.cs | 9 + ...ewFloatingTieredPackageWithMinimumPrice.cs | 9 + src/Orb/Models/NewFloatingTieredPrice.cs | 3 + .../NewFloatingTieredWithMinimumPrice.cs | 9 + .../NewFloatingTieredWithProrationPrice.cs | 9 + src/Orb/Models/NewFloatingUnitPrice.cs | 3 + .../Models/NewFloatingUnitWithPercentPrice.cs | 6 + .../NewFloatingUnitWithProrationPrice.cs | 6 + src/Orb/Models/NewMaximum.cs | 6 + src/Orb/Models/NewMinimum.cs | 6 + src/Orb/Models/NewPercentageDiscount.cs | 6 + src/Orb/Models/NewPlanBulkPrice.cs | 3 + .../Models/NewPlanBulkWithProrationPrice.cs | 9 + .../NewPlanCumulativeGroupedBulkPrice.cs | 9 + .../Models/NewPlanGroupedAllocationPrice.cs | 6 + .../NewPlanGroupedTieredPackagePrice.cs | 9 + src/Orb/Models/NewPlanGroupedTieredPrice.cs | 9 + .../NewPlanGroupedWithMeteredMinimumPrice.cs | 12 + .../NewPlanGroupedWithProratedMinimumPrice.cs | 6 + src/Orb/Models/NewPlanMatrixPrice.cs | 3 + .../NewPlanMatrixWithAllocationPrice.cs | 3 + .../NewPlanMatrixWithDisplayNamePrice.cs | 9 + .../NewPlanMaxGroupTieredPackagePrice.cs | 9 + .../Models/NewPlanMinimumCompositePrice.cs | 6 + src/Orb/Models/NewPlanPackagePrice.cs | 3 + .../NewPlanPackageWithAllocationPrice.cs | 6 + ...lanScalableMatrixWithTieredPricingPrice.cs | 12 + ...wPlanScalableMatrixWithUnitPricingPrice.cs | 9 + .../NewPlanThresholdTotalAmountPrice.cs | 9 + src/Orb/Models/NewPlanTieredPackagePrice.cs | 9 + .../NewPlanTieredPackageWithMinimumPrice.cs | 9 + src/Orb/Models/NewPlanTieredPrice.cs | 3 + .../Models/NewPlanTieredWithMinimumPrice.cs | 9 + src/Orb/Models/NewPlanUnitPrice.cs | 3 + src/Orb/Models/NewPlanUnitWithPercentPrice.cs | 6 + .../Models/NewPlanUnitWithProrationPrice.cs | 6 + src/Orb/Models/NewUsageDiscount.cs | 6 + src/Orb/Models/OtherSubLineItem.cs | 3 + src/Orb/Models/PackageConfig.cs | 3 + src/Orb/Models/PaginationMetadata.cs | 3 + src/Orb/Models/PerPriceCost.cs | 3 + src/Orb/Models/PercentageDiscount.cs | 6 + src/Orb/Models/PercentageDiscountInterval.cs | 6 + .../PlanPhaseAmountDiscountAdjustment.cs | 6 + src/Orb/Models/PlanPhaseMaximumAdjustment.cs | 6 + src/Orb/Models/PlanPhaseMinimumAdjustment.cs | 6 + .../PlanPhasePercentageDiscountAdjustment.cs | 6 + .../PlanPhaseUsageDiscountAdjustment.cs | 6 + .../Migrations/MigrationCancelResponse.cs | 3 + .../Migrations/MigrationListPageResponse.cs | 3 + .../Plans/Migrations/MigrationListResponse.cs | 3 + .../Migrations/MigrationRetrieveResponse.cs | 3 + src/Orb/Models/Plans/Plan.cs | 15 + src/Orb/Models/Plans/PlanCreateParams.cs | 54 + src/Orb/Models/Plans/PlanListPageResponse.cs | 3 + src/Orb/Models/Price.cs | 315 + src/Orb/Models/PriceInterval.cs | 3 + src/Orb/Models/Prices/EvaluatePriceGroup.cs | 3 + src/Orb/Models/Prices/PriceCreateParams.cs | 36 + .../Prices/PriceEvaluateMultipleParams.cs | 39 + .../Prices/PriceEvaluateMultipleResponse.cs | 6 + .../PriceEvaluatePreviewEventsParams.cs | 42 + .../PriceEvaluatePreviewEventsResponse.cs | 6 + .../Models/Prices/PriceEvaluateResponse.cs | 3 + .../Models/Prices/PriceListPageResponse.cs | 3 + src/Orb/Models/SharedCreditNote.cs | 21 + src/Orb/Models/SharedTier.cs | 3 + .../SharedTieredConversionRateConfig.cs | 3 + .../Models/SharedUnitConversionRateConfig.cs | 3 + src/Orb/Models/SubLineItemGrouping.cs | 3 + src/Orb/Models/SubLineItemMatrixConfig.cs | 3 + src/Orb/Models/SubscriptionChangeMinified.cs | 3 + .../MutatedSubscription.cs | 3 + .../SubscriptionChangeApplyResponse.cs | 3 + .../SubscriptionChangeCancelResponse.cs | 3 + .../SubscriptionChangeListPageResponse.cs | 3 + .../SubscriptionChangeListResponse.cs | 3 + .../SubscriptionChangeRetrieveResponse.cs | 3 + src/Orb/Models/SubscriptionMinified.cs | 3 + src/Orb/Models/SubscriptionTrialInfo.cs | 3 + .../Models/Subscriptions/DiscountOverride.cs | 3 + .../Subscriptions/NewSubscriptionBulkPrice.cs | 3 + .../NewSubscriptionBulkWithProrationPrice.cs | 9 + ...wSubscriptionCumulativeGroupedBulkPrice.cs | 9 + .../NewSubscriptionGroupedAllocationPrice.cs | 6 + ...ewSubscriptionGroupedTieredPackagePrice.cs | 9 + .../NewSubscriptionGroupedTieredPrice.cs | 9 + ...scriptionGroupedWithMeteredMinimumPrice.cs | 12 + ...criptionGroupedWithProratedMinimumPrice.cs | 6 + .../NewSubscriptionMatrixPrice.cs | 3 + ...ewSubscriptionMatrixWithAllocationPrice.cs | 3 + ...wSubscriptionMatrixWithDisplayNamePrice.cs | 9 + ...wSubscriptionMaxGroupTieredPackagePrice.cs | 9 + .../NewSubscriptionMinimumCompositePrice.cs | 6 + .../NewSubscriptionPackagePrice.cs | 3 + ...wSubscriptionPackageWithAllocationPrice.cs | 6 + ...ionScalableMatrixWithTieredPricingPrice.cs | 12 + ...ptionScalableMatrixWithUnitPricingPrice.cs | 9 + ...ewSubscriptionThresholdTotalAmountPrice.cs | 9 + .../NewSubscriptionTieredPackagePrice.cs | 9 + ...bscriptionTieredPackageWithMinimumPrice.cs | 9 + .../NewSubscriptionTieredPrice.cs | 3 + .../NewSubscriptionTieredWithMinimumPrice.cs | 9 + .../Subscriptions/NewSubscriptionUnitPrice.cs | 3 + .../NewSubscriptionUnitWithPercentPrice.cs | 6 + .../NewSubscriptionUnitWithProrationPrice.cs | 6 + src/Orb/Models/Subscriptions/Subscription.cs | 3 + .../Subscriptions/SubscriptionCreateParams.cs | 108 + .../SubscriptionFetchCostsResponse.cs | 3 + .../SubscriptionFetchSchedulePageResponse.cs | 3 + .../SubscriptionFetchScheduleResponse.cs | 6 + .../SubscriptionPriceIntervalsParams.cs | 63 + .../SubscriptionSchedulePlanChangeParams.cs | 108 + .../SubscriptionSubscriptions.cs | 3 + .../Models/Subscriptions/SubscriptionUsage.cs | 27 + src/Orb/Models/TaxAmount.cs | 3 + src/Orb/Models/TierSubLineItem.cs | 6 + src/Orb/Models/TieredConfig.cs | 3 + .../Models/TopLevel/TopLevelPingResponse.cs | 3 + src/Orb/Models/TrialDiscount.cs | 6 + src/Orb/Models/UnitConfig.cs | 3 + src/Orb/Models/UsageDiscount.cs | 6 + src/Orb/Models/UsageDiscountInterval.cs | 6 + 530 files changed, 41238 insertions(+), 1977 deletions(-) diff --git a/src/Orb.Tests/Models/AddressTest.cs b/src/Orb.Tests/Models/AddressTest.cs index 58bc755ba..60c137064 100644 --- a/src/Orb.Tests/Models/AddressTest.cs +++ b/src/Orb.Tests/Models/AddressTest.cs @@ -103,4 +103,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Address + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + + Address copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/AdjustmentIntervalTest.cs b/src/Orb.Tests/Models/AdjustmentIntervalTest.cs index 047e2266d..aad0613f4 100644 --- a/src/Orb.Tests/Models/AdjustmentIntervalTest.cs +++ b/src/Orb.Tests/Models/AdjustmentIntervalTest.cs @@ -231,6 +231,42 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AdjustmentInterval + { + ID = "id", + Adjustment = new PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + AdjustmentInterval copied = new(model); + + Assert.Equal(model, copied); + } } public class AdjustmentTest : TestBase diff --git a/src/Orb.Tests/Models/AggregatedCostTest.cs b/src/Orb.Tests/Models/AggregatedCostTest.cs index 2d091dcbf..bc941ea2f 100644 --- a/src/Orb.Tests/Models/AggregatedCostTest.cs +++ b/src/Orb.Tests/Models/AggregatedCostTest.cs @@ -844,4 +844,144 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AggregatedCost + { + PerPriceCosts = + [ + new() + { + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + PriceID = "price_id", + Subtotal = "subtotal", + Total = "total", + Quantity = 0, + }, + ], + Subtotal = "subtotal", + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "total", + }; + + AggregatedCost copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs b/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs index 08fc76f49..844dcd23a 100644 --- a/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs @@ -225,4 +225,40 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AlertListPageResponse + { + Data = + [ + new() + { + ID = "XuxCbt7x9L82yyeF", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Enabled = true, + Metric = new("id"), + Plan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + PlanVersion = "plan_version", + }, + Subscription = new("VDGsT23osdLb84KD"), + Thresholds = [new(0)], + Type = AlertType.CreditBalanceDepleted, + BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + AlertListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Alerts/AlertTest.cs b/src/Orb.Tests/Models/Alerts/AlertTest.cs index 70f2dffe9..a28d97a9d 100644 --- a/src/Orb.Tests/Models/Alerts/AlertTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertTest.cs @@ -324,6 +324,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Alert + { + ID = "XuxCbt7x9L82yyeF", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Enabled = true, + Metric = new("id"), + Plan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + PlanVersion = "plan_version", + }, + Subscription = new("VDGsT23osdLb84KD"), + Thresholds = [new(0)], + Type = AlertType.CreditBalanceDepleted, + BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + }; + + Alert copied = new(model); + + Assert.Equal(model, copied); + } } public class MetricTest : TestBase @@ -370,6 +399,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Metric { ID = "id" }; + + Metric copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanTest : TestBase @@ -452,6 +491,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Plan + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + PlanVersion = "plan_version", + }; + + Plan copied = new(model); + + Assert.Equal(model, copied); + } } public class AlertTypeTest : TestBase @@ -572,4 +627,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BalanceAlertStatus { InAlert = true, ThresholdValue = 0 }; + + BalanceAlertStatus copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Alerts/ThresholdTest.cs b/src/Orb.Tests/Models/Alerts/ThresholdTest.cs index ba8ca359b..b58e630ef 100644 --- a/src/Orb.Tests/Models/Alerts/ThresholdTest.cs +++ b/src/Orb.Tests/Models/Alerts/ThresholdTest.cs @@ -51,4 +51,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Threshold { Value = 0 }; + + Threshold copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/AllocationTest.cs b/src/Orb.Tests/Models/AllocationTest.cs index d98268ecc..331aff215 100644 --- a/src/Orb.Tests/Models/AllocationTest.cs +++ b/src/Orb.Tests/Models/AllocationTest.cs @@ -250,6 +250,34 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Allocation + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + }; + + Allocation copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -332,6 +360,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class FieldTest : TestBase diff --git a/src/Orb.Tests/Models/AmountDiscountIntervalTest.cs b/src/Orb.Tests/Models/AmountDiscountIntervalTest.cs index 91daea3eb..0920e3de0 100644 --- a/src/Orb.Tests/Models/AmountDiscountIntervalTest.cs +++ b/src/Orb.Tests/Models/AmountDiscountIntervalTest.cs @@ -184,6 +184,32 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AmountDiscountInterval + { + AmountDiscount = "amount_discount", + AppliesToPriceIntervalIds = ["string"], + DiscountType = AmountDiscountIntervalDiscountType.Amount, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AmountDiscountIntervalFilterField.PriceID, + Operator = AmountDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + AmountDiscountInterval copied = new(model); + + Assert.Equal(model, copied); + } } public class AmountDiscountIntervalDiscountTypeTest : TestBase @@ -330,6 +356,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AmountDiscountIntervalFilter + { + Field = AmountDiscountIntervalFilterField.PriceID, + Operator = AmountDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }; + + AmountDiscountIntervalFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class AmountDiscountIntervalFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/AmountDiscountTest.cs b/src/Orb.Tests/Models/AmountDiscountTest.cs index 0f091a637..abdae0b14 100644 --- a/src/Orb.Tests/Models/AmountDiscountTest.cs +++ b/src/Orb.Tests/Models/AmountDiscountTest.cs @@ -234,6 +234,31 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AmountDiscount + { + AmountDiscountValue = "amount_discount", + DiscountType = DiscountType.Amount, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = AmountDiscountFilterField.PriceID, + Operator = AmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }; + + AmountDiscount copied = new(model); + + Assert.Equal(model, copied); + } } public class DiscountTypeTest : TestBase @@ -382,6 +407,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AmountDiscountFilter + { + Field = AmountDiscountFilterField.PriceID, + Operator = AmountDiscountFilterOperator.Includes, + Values = ["string"], + }; + + AmountDiscountFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class AmountDiscountFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs index 7cad18738..6e6fd67d4 100644 --- a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs @@ -1053,6 +1053,39 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AddAdjustment + { + 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, + }; + + AddAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class AdjustmentTest : TestBase @@ -1835,6 +1868,81 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AddPrice + { + 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", + }, + }; + + AddPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceTest : TestBase @@ -5628,6 +5736,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new 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 = Cadence.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", + }; + + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigTest : TestBase @@ -5740,6 +5902,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -5790,6 +5970,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class TierTest : TestBase @@ -5884,6 +6074,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -6500,6 +6700,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + Cadence = 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 = 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", + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationCadenceTest : TestBase @@ -6644,6 +6892,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationConfigTierTest : TestBase @@ -6716,17 +6977,31 @@ public void Validation_Works() model.Validate(); } -} -public class TieredWithProrationConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void CopyConstructor_Works() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + var model = new TieredWithProrationConfigTier { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; value.Validate(); } @@ -7318,6 +7593,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = 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 = 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", + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -7470,6 +7797,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -8076,6 +8419,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = 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 = 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", + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -8228,6 +8623,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -8759,6 +9170,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Percent + { + Cadence = PercentCadence.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", + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentCadenceTest : TestBase @@ -8877,6 +9334,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentConversionRateConfigTest : TestBase @@ -9455,6 +9922,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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", + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputCadenceTest : TestBase @@ -9651,6 +10169,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputConversionRateConfigTest : TestBase @@ -9828,6 +10361,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + + RemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class RemovePriceTest : TestBase @@ -9928,6 +10471,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + + RemovePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplaceAdjustmentTest : TestBase @@ -10151,12 +10704,43 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() ReplacesAdjustmentID = "replaces_adjustment_id", }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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", + }; + + model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new ReplaceAdjustment { @@ -10181,13 +10765,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", + + PlanPhaseOrder = null, }; - model.Validate(); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new ReplaceAdjustment { @@ -10216,12 +10803,11 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() PlanPhaseOrder = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { var model = new ReplaceAdjustment { @@ -10246,11 +10832,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, + PlanPhaseOrder = 0, }; - model.Validate(); + ReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); } } @@ -11049,6 +11636,82 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePrice + { + 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", + }, + }; + + ReplacePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTest : TestBase @@ -14937,6 +15600,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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", + }; + + ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase @@ -15057,6 +15774,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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" }, + ], + }; + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase @@ -15131,6 +15866,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase @@ -15255,6 +16004,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase @@ -15871,6 +16634,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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 = "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", + }; + + ReplacePricePriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase @@ -16013,6 +16824,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + ReplacePricePriceTieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase @@ -16072,12 +16896,24 @@ public void FieldRoundtripThroughSerialization_Works() string expectedTierLowerBound = "tier_lower_bound"; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + 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(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { @@ -16085,7 +16921,9 @@ public void Validation_Works() UnitAmount = "unit_amount", }; - model.Validate(); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); } } @@ -16695,6 +17533,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceGroupedWithMinMaxThresholds + { + Cadence = 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 = 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", + }; + + ReplacePricePriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -16854,6 +17744,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -17462,6 +18371,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + ReplacePricePriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase @@ -17621,6 +18582,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -18157,6 +19137,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + ReplacePricePricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentCadenceTest : TestBase @@ -18273,6 +19299,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePricePercentPercentConfig { Percent = 0 }; + + ReplacePricePricePercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentConversionRateConfigTest : TestBase @@ -18857,6 +19893,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + ReplacePricePriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputCadenceTest : TestBase @@ -19051,6 +20138,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + ReplacePricePriceEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs index 473bc2f81..3ec961622 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs @@ -1064,6 +1064,39 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AddAdjustment + { + 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, + }; + + AddAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class AdjustmentTest : TestBase @@ -1846,6 +1879,81 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AddPrice + { + 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", + }, + }; + + AddPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceTest : TestBase @@ -5639,6 +5747,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new 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 = Cadence.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", + }; + + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigTest : TestBase @@ -5751,6 +5913,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -5801,6 +5981,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class TierTest : TestBase @@ -5895,6 +6085,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -6511,6 +6711,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + Cadence = 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 = 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", + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationCadenceTest : TestBase @@ -6655,6 +6903,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationConfigTierTest : TestBase @@ -6727,17 +6988,31 @@ public void Validation_Works() model.Validate(); } -} -public class TieredWithProrationConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void CopyConstructor_Works() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + var model = new TieredWithProrationConfigTier { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; value.Validate(); } @@ -7329,6 +7604,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = 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 = 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", + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -7481,6 +7808,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -8087,6 +8430,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = 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 = 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", + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -8239,6 +8634,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -8770,6 +9181,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Percent + { + Cadence = PercentCadence.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", + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentCadenceTest : TestBase @@ -8888,6 +9345,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentConversionRateConfigTest : TestBase @@ -9466,6 +9933,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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", + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputCadenceTest : TestBase @@ -9662,6 +10180,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputConversionRateConfigTest : TestBase @@ -9839,6 +10372,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + + RemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class RemovePriceTest : TestBase @@ -9939,6 +10482,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + + RemovePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplaceAdjustmentTest : TestBase @@ -10162,12 +10715,43 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() ReplacesAdjustmentID = "replaces_adjustment_id", }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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", + }; + + model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new ReplaceAdjustment { @@ -10192,13 +10776,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", + + PlanPhaseOrder = null, }; - model.Validate(); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new ReplaceAdjustment { @@ -10227,12 +10814,11 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() PlanPhaseOrder = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { var model = new ReplaceAdjustment { @@ -10257,11 +10843,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, + PlanPhaseOrder = 0, }; - model.Validate(); + ReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); } } @@ -11060,6 +11647,82 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePrice + { + 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", + }, + }; + + ReplacePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTest : TestBase @@ -14948,6 +15611,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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", + }; + + ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase @@ -15068,6 +15785,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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" }, + ], + }; + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase @@ -15142,6 +15877,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase @@ -15266,6 +16015,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase @@ -15882,6 +16645,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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 = "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", + }; + + ReplacePricePriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase @@ -16024,6 +16835,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + ReplacePricePriceTieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase @@ -16083,12 +16907,24 @@ public void FieldRoundtripThroughSerialization_Works() string expectedTierLowerBound = "tier_lower_bound"; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + 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(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { @@ -16096,7 +16932,9 @@ public void Validation_Works() UnitAmount = "unit_amount", }; - model.Validate(); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); } } @@ -16706,6 +17544,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceGroupedWithMinMaxThresholds + { + Cadence = 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 = 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", + }; + + ReplacePricePriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -16865,6 +17755,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -17473,6 +18382,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + ReplacePricePriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase @@ -17632,6 +18593,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -18168,6 +19148,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + ReplacePricePricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentCadenceTest : TestBase @@ -18284,6 +19310,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePricePercentPercentConfig { Percent = 0 }; + + ReplacePricePricePercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentConversionRateConfigTest : TestBase @@ -18868,6 +19904,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + ReplacePricePriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputCadenceTest : TestBase @@ -19062,6 +20149,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + ReplacePricePriceEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Beta/PlanVersionPhaseTest.cs b/src/Orb.Tests/Models/Beta/PlanVersionPhaseTest.cs index 7fc3b77df..cd7997d10 100644 --- a/src/Orb.Tests/Models/Beta/PlanVersionPhaseTest.cs +++ b/src/Orb.Tests/Models/Beta/PlanVersionPhaseTest.cs @@ -107,6 +107,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanVersionPhase + { + ID = "id", + Description = "description", + Duration = 0, + DurationUnit = DurationUnit.Daily, + Name = "name", + Order = 0, + }; + + PlanVersionPhase copied = new(model); + + Assert.Equal(model, copied); + } } public class DurationUnitTest : TestBase diff --git a/src/Orb.Tests/Models/Beta/PlanVersionTest.cs b/src/Orb.Tests/Models/Beta/PlanVersionTest.cs index 387e9294e..1ced2437d 100644 --- a/src/Orb.Tests/Models/Beta/PlanVersionTest.cs +++ b/src/Orb.Tests/Models/Beta/PlanVersionTest.cs @@ -1031,6 +1031,174 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanVersion + { + Adjustments = + [ + new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + Duration = 0, + DurationUnit = DurationUnit.Daily, + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Version = 0, + }; + + PlanVersion copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanVersionAdjustmentTest : TestBase diff --git a/src/Orb.Tests/Models/BillableMetricTinyTest.cs b/src/Orb.Tests/Models/BillableMetricTinyTest.cs index b5e8f80bc..6bfe39d0e 100644 --- a/src/Orb.Tests/Models/BillableMetricTinyTest.cs +++ b/src/Orb.Tests/Models/BillableMetricTinyTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BillableMetricTiny { ID = "id" }; + + BillableMetricTiny copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/BillingCycleAnchorConfigurationTest.cs b/src/Orb.Tests/Models/BillingCycleAnchorConfigurationTest.cs index ea46a0d5b..2b7db5f26 100644 --- a/src/Orb.Tests/Models/BillingCycleAnchorConfigurationTest.cs +++ b/src/Orb.Tests/Models/BillingCycleAnchorConfigurationTest.cs @@ -132,4 +132,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BillingCycleAnchorConfiguration + { + Day = 1, + Month = 1, + Year = 0, + }; + + BillingCycleAnchorConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/BillingCycleConfigurationTest.cs b/src/Orb.Tests/Models/BillingCycleConfigurationTest.cs index 566a86a7b..26dd42777 100644 --- a/src/Orb.Tests/Models/BillingCycleConfigurationTest.cs +++ b/src/Orb.Tests/Models/BillingCycleConfigurationTest.cs @@ -59,6 +59,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BillingCycleConfiguration { Duration = 0, DurationUnit = DurationUnit.Day }; + + BillingCycleConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class DurationUnitTest : TestBase diff --git a/src/Orb.Tests/Models/BulkConfigTest.cs b/src/Orb.Tests/Models/BulkConfigTest.cs index 197bdc2c8..d8e41f238 100644 --- a/src/Orb.Tests/Models/BulkConfigTest.cs +++ b/src/Orb.Tests/Models/BulkConfigTest.cs @@ -75,4 +75,17 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkConfig + { + Tiers = [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }], + }; + + BulkConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/BulkTierTest.cs b/src/Orb.Tests/Models/BulkTierTest.cs index 547ea9f5e..b7457208d 100644 --- a/src/Orb.Tests/Models/BulkTierTest.cs +++ b/src/Orb.Tests/Models/BulkTierTest.cs @@ -99,4 +99,14 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkTier { UnitAmount = "unit_amount", MaximumUnits = 0 }; + + BulkTier copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/ChangedSubscriptionResourcesTest.cs b/src/Orb.Tests/Models/ChangedSubscriptionResourcesTest.cs index 0c0ee238a..59d0add06 100644 --- a/src/Orb.Tests/Models/ChangedSubscriptionResourcesTest.cs +++ b/src/Orb.Tests/Models/ChangedSubscriptionResourcesTest.cs @@ -5083,534 +5083,1378 @@ public void Validation_Works() model.Validate(); } -} -public class CreatedInvoiceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new Models::CreatedInvoice + var model = new Models::ChangedSubscriptionResources { - ID = "id", - AmountDue = "8.00", - AutoCollection = new() - { - Enabled = true, - NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - NumAttempts = 0, - PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }, - BillingAddress = new() - { - City = "city", - Country = "country", - Line1 = "line1", - Line2 = "line2", - PostalCode = "postal_code", - State = "state", - }, - CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - CreditNotes = + CreatedCreditNotes = [ new() { ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartTimeInclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, Memo = "memo", - Reason = "reason", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", Total = "total", - Type = "type", - VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - }, - ], - Currency = "USD", - Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, - CustomerBalanceTransactions = - [ - new() - { - ID = "cgZa3SXcsPTVyC4Y", - Action = Models::Action.AppliedToInvoice, - Amount = "11.00", - CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - CreditNote = new("id"), - Description = "An optional description", - EndingBalance = "22.00", - Invoice = new("gXcsPTVyC4YZa3Sc"), - StartingBalance = "33.00", - Type = Models::Type.Increment, - }, - ], - CustomerTaxID = new() - { - Country = Models::Country.Ad, - Type = Models::CustomerTaxIDType.AdNrt, - Value = "value", - }, - Discount = JsonSerializer.Deserialize("{}"), - Discounts = - [ - new Models::PercentageDiscount() - { - DiscountType = Models::PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = [ new() { - Field = Models::PercentageDiscountFilterField.PriceID, - Operator = Models::PercentageDiscountFilterOperator.Includes, - Values = ["string"], + AmountApplied = "amount_applied", + DiscountType = Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", }, ], - Reason = "reason", }, ], - DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), - EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - HostedInvoiceUrl = "hosted_invoice_url", - InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), - InvoiceNumber = "JYEFHK-00001", - InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", - InvoiceSource = Models::InvoiceSource.Subscription, - IsPayableNow = true, - IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - LineItems = + CreatedInvoices = [ new() { ID = "id", - AdjustedSubtotal = "5.00", - Adjustments = + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = [ - new Models::MonetaryUsageDiscountAdjustment() + new() { ID = "id", - AdjustmentType = - Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, - Amount = "amount", - AppliesToPriceIds = ["string"], + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + new Models::PercentageDiscount() + { + DiscountType = Models::PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], Filters = [ new() { - Field = - Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, - Operator = - Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, Reason = "reason", - ReplacesAdjustmentID = "replaces_adjustment_id", - UsageDiscount = 0, }, ], - Amount = "7.00", - CreditsApplied = "6.00", - EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), - Filter = "filter", - Grouping = "grouping", - Name = "Fixed Fee", - PartiallyInvoicedAmount = "4.00", - Price = new Models::Unit() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceSource.Subscription, + IsPayableNow = true, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - BillingMode = Models::BillingMode.InAdvance, - Cadence = Models::UnitCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = Models::CompositePriceFilterField.PriceID, - Operator = Models::CompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = - Models::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 = Models::CustomExpirationDurationUnit.Day, - }, - Filters = + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = [ - new() + new Models::MonetaryUsageDiscountAdjustment() { - Field = Models::Field.PriceID, - Operator = Models::Operator.Includes, - Values = ["string"], + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, }, ], - }, - Currency = "currency", - Discount = new Models::PercentageDiscount() - { - DiscountType = Models::PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { - Field = Models::PercentageDiscountFilterField.PriceID, - Operator = Models::PercentageDiscountFilterOperator.Includes, - Values = ["string"], + Duration = 0, + DurationUnit = Models::DurationUnit.Day, }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = [ - new() + new Models::MatrixSubLineItem() { - Field = Models::MaximumFilterField.PriceID, - Operator = Models::MaximumFilterOperator.Includes, - Values = ["string"], + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, }, ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = + Subtotal = "9.00", + TaxAmounts = [ new() { - Field = Models::MinimumFilterField.PriceID, - Operator = Models::MinimumFilterOperator.Includes, - Values = ["string"], + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", }, ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = Models::UnitPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }, - Quantity = 1, - StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), - SubLineItems = - [ - new Models::MatrixSubLineItem() - { - Amount = "9.00", - Grouping = new() { Key = "region", Value = "west" }, - MatrixConfig = new(["string"]), - Name = "Tier One", - Quantity = 5, - Type = Models::MatrixSubLineItemType.Matrix, - ScaledQuantity = 0, + UsageCustomerIds = ["string"], }, ], - Subtotal = "9.00", - TaxAmounts = - [ - new() - { - Amount = "amount", - TaxRateDescription = "tax_rate_description", - TaxRatePercentage = "tax_rate_percentage", - }, - ], - UsageCustomerIds = ["string"], - }, - ], - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = Models::MaximumFilterField.PriceID, - Operator = Models::MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Memo = "memo", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = Models::MinimumFilterField.PriceID, - Operator = Models::MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentAttempts = - [ - new() - { - ID = "id", - Amount = "amount", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentProvider = Models::PaymentProvider.Stripe, - PaymentProviderID = "payment_provider_id", - ReceiptPdf = - "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", - Succeeded = true, - }, - ], - PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ShippingAddress = new() - { - City = "city", - Country = "country", - Line1 = "line1", - Line2 = "line2", - PostalCode = "postal_code", - State = "state", - }, - Status = Models::Status.Issued, - Subscription = new("VDGsT23osdLb84KD"), - Subtotal = "8.00", - SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Total = "8.00", - VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - WillAutoIssue = true, - }; - - string expectedID = "id"; - string expectedAmountDue = "8.00"; - Models::AutoCollection expectedAutoCollection = new() - { - Enabled = true, - NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - NumAttempts = 0, - PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - Models::Address expectedBillingAddress = new() - { - City = "city", - Country = "country", - Line1 = "line1", - Line2 = "line2", - PostalCode = "postal_code", - State = "state", - }; - DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); - List expectedCreditNotes = - [ - new() - { - ID = "id", - CreditNoteNumber = "credit_note_number", - Memo = "memo", - Reason = "reason", - Total = "total", - Type = "type", - VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - }, - ]; - string expectedCurrency = "USD"; - Models::CustomerMinified expectedCustomer = new() - { - ID = "id", - ExternalCustomerID = "external_customer_id", - }; - List expectedCustomerBalanceTransactions = - [ - new() - { - ID = "cgZa3SXcsPTVyC4Y", - Action = Models::Action.AppliedToInvoice, - Amount = "11.00", - CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - CreditNote = new("id"), - Description = "An optional description", - EndingBalance = "22.00", - Invoice = new("gXcsPTVyC4YZa3Sc"), - StartingBalance = "33.00", - Type = Models::Type.Increment, - }, - ]; - Models::CustomerTaxID expectedCustomerTaxID = new() - { - Country = Models::Country.Ad, - Type = Models::CustomerTaxIDType.AdNrt, - Value = "value", - }; - JsonElement expectedDiscount = JsonSerializer.Deserialize("{}"); - List expectedDiscounts = - [ - 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", - }, - ]; - DateTimeOffset expectedDueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"); - DateTimeOffset expectedEligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedHostedInvoiceUrl = "hosted_invoice_url"; - DateTimeOffset expectedInvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"); - string expectedInvoiceNumber = "JYEFHK-00001"; - string expectedInvoicePdf = - "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb"; - ApiEnum expectedInvoiceSource = - Models::InvoiceSource.Subscription; - bool expectedIsPayableNow = true; - DateTimeOffset expectedIssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DateTimeOffset expectedIssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - List expectedLineItems = - [ - new() - { - ID = "id", - AdjustedSubtotal = "5.00", - Adjustments = - [ - new Models::MonetaryUsageDiscountAdjustment() + Maximum = new() { - ID = "id", - AdjustmentType = - Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, - Amount = "amount", AppliesToPriceIds = ["string"], Filters = [ new() { - Field = Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, - Operator = - Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - Reason = "reason", - ReplacesAdjustmentID = "replaces_adjustment_id", - UsageDiscount = 0, - }, - ], - Amount = "7.00", - CreditsApplied = "6.00", - EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), - Filter = "filter", - Grouping = "grouping", - Name = "Fixed Fee", - PartiallyInvoicedAmount = "4.00", - Price = new Models::Unit() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - BillingMode = Models::BillingMode.InAdvance, - Cadence = Models::UnitCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = Models::CompositePriceFilterField.PriceID, - Operator = Models::CompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = - Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + MaximumAmount = "maximum_amount", }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, + AppliesToPriceIds = ["string"], Filters = [ new() { - Field = Models::Field.PriceID, - Operator = Models::Operator.Includes, + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, Values = ["string"], }, ], + MinimumAmount = "minimum_amount", }, - Currency = "currency", - Discount = new Models::PercentageDiscount() - { - DiscountType = Models::PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::Status.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + VoidedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartTimeInclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + VoidedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + Models::InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + }; + + Models::ChangedSubscriptionResources copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CreatedInvoiceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Models::CreatedInvoice + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceSource.Subscription, + IsPayableNow = true, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::Status.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + string expectedID = "id"; + string expectedAmountDue = "8.00"; + Models::AutoCollection expectedAutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + Models::Address expectedBillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); + List expectedCreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ]; + string expectedCurrency = "USD"; + Models::CustomerMinified expectedCustomer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }; + List expectedCustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ]; + Models::CustomerTaxID expectedCustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }; + JsonElement expectedDiscount = JsonSerializer.Deserialize("{}"); + List expectedDiscounts = + [ + 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", + }, + ]; + DateTimeOffset expectedDueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"); + DateTimeOffset expectedEligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedHostedInvoiceUrl = "hosted_invoice_url"; + DateTimeOffset expectedInvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"); + string expectedInvoiceNumber = "JYEFHK-00001"; + string expectedInvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb"; + ApiEnum expectedInvoiceSource = + Models::InvoiceSource.Subscription; + bool expectedIsPayableNow = true; + DateTimeOffset expectedIssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedIssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + List expectedLineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + Discount = new Models::PercentageDiscount() + { + DiscountType = Models::PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = [ new() { @@ -5631,218 +6475,567 @@ public void FieldRoundtrip_Works() Item = new() { ID = "id", Name = "name" }, Maximum = new() { - AppliesToPriceIds = ["string"], - Filters = + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ]; + Models::Maximum expectedMaximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }; + string expectedMaximumAmount = "maximum_amount"; + string expectedMemo = "memo"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + Models::Minimum expectedMinimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }; + string expectedMinimumAmount = "minimum_amount"; + DateTimeOffset expectedPaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + List expectedPaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ]; + DateTimeOffset expectedPaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedPaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Models::Address expectedShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + ApiEnum expectedStatus = Models::Status.Issued; + Models::SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); + string expectedSubtotal = "8.00"; + DateTimeOffset expectedSyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedTotal = "8.00"; + DateTimeOffset expectedVoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + bool expectedWillAutoIssue = true; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedAmountDue, model.AmountDue); + Assert.Equal(expectedAutoCollection, model.AutoCollection); + Assert.Equal(expectedBillingAddress, model.BillingAddress); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedCreditNotes.Count, model.CreditNotes.Count); + for (int i = 0; i < expectedCreditNotes.Count; i++) + { + Assert.Equal(expectedCreditNotes[i], model.CreditNotes[i]); + } + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedCustomer, model.Customer); + Assert.Equal( + expectedCustomerBalanceTransactions.Count, + model.CustomerBalanceTransactions.Count + ); + for (int i = 0; i < expectedCustomerBalanceTransactions.Count; i++) + { + Assert.Equal( + expectedCustomerBalanceTransactions[i], + model.CustomerBalanceTransactions[i] + ); + } + Assert.Equal(expectedCustomerTaxID, model.CustomerTaxID); + Assert.True(JsonElement.DeepEquals(expectedDiscount, model.Discount)); + Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], model.Discounts[i]); + } + Assert.Equal(expectedDueDate, model.DueDate); + Assert.Equal(expectedEligibleToIssueAt, model.EligibleToIssueAt); + Assert.Equal(expectedHostedInvoiceUrl, model.HostedInvoiceUrl); + Assert.Equal(expectedInvoiceDate, model.InvoiceDate); + Assert.Equal(expectedInvoiceNumber, model.InvoiceNumber); + Assert.Equal(expectedInvoicePdf, model.InvoicePdf); + Assert.Equal(expectedInvoiceSource, model.InvoiceSource); + Assert.Equal(expectedIsPayableNow, model.IsPayableNow); + Assert.Equal(expectedIssueFailedAt, model.IssueFailedAt); + Assert.Equal(expectedIssuedAt, model.IssuedAt); + Assert.Equal(expectedLineItems.Count, model.LineItems.Count); + for (int i = 0; i < expectedLineItems.Count; i++) + { + Assert.Equal(expectedLineItems[i], model.LineItems[i]); + } + Assert.Equal(expectedMaximum, model.Maximum); + Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.Equal(expectedMemo, model.Memo); + 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(expectedPaidAt, model.PaidAt); + Assert.Equal(expectedPaymentAttempts.Count, model.PaymentAttempts.Count); + for (int i = 0; i < expectedPaymentAttempts.Count; i++) + { + Assert.Equal(expectedPaymentAttempts[i], model.PaymentAttempts[i]); + } + Assert.Equal(expectedPaymentFailedAt, model.PaymentFailedAt); + Assert.Equal(expectedPaymentStartedAt, model.PaymentStartedAt); + Assert.Equal(expectedScheduledIssueAt, model.ScheduledIssueAt); + Assert.Equal(expectedShippingAddress, model.ShippingAddress); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedSubscription, model.Subscription); + Assert.Equal(expectedSubtotal, model.Subtotal); + Assert.Equal(expectedSyncFailedAt, model.SyncFailedAt); + Assert.Equal(expectedTotal, model.Total); + Assert.Equal(expectedVoidedAt, model.VoidedAt); + Assert.Equal(expectedWillAutoIssue, model.WillAutoIssue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Models::CreatedInvoice + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceSource.Subscription, + IsPayableNow = true, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = [ new() { - Field = Models::MaximumFilterField.PriceID, - Operator = Models::MaximumFilterOperator.Includes, + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, Values = ["string"], }, ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() { - Field = Models::MinimumFilterField.PriceID, - Operator = Models::MinimumFilterOperator.Includes, - Values = ["string"], + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, }, - ], + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = Models::UnitPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], }, - Quantity = 1, - StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), - SubLineItems = + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ - new Models::MatrixSubLineItem() + new() { - Amount = "9.00", - Grouping = new() { Key = "region", Value = "west" }, - MatrixConfig = new(["string"]), - Name = "Tier One", - Quantity = 5, - Type = Models::MatrixSubLineItemType.Matrix, - ScaledQuantity = 0, + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], }, ], - Subtotal = "9.00", - TaxAmounts = + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ new() { - Amount = "amount", - TaxRateDescription = "tax_rate_description", - TaxRatePercentage = "tax_rate_percentage", + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], }, ], - UsageCustomerIds = ["string"], + MinimumAmount = "minimum_amount", }, - ]; - Models::Maximum expectedMaximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = Models::MaximumFilterField.PriceID, - Operator = Models::MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }; - string expectedMaximumAmount = "maximum_amount"; - string expectedMemo = "memo"; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - Models::Minimum expectedMinimum = new() - { - AppliesToPriceIds = ["string"], - Filters = + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = [ new() { - Field = Models::MinimumFilterField.PriceID, - Operator = Models::MinimumFilterOperator.Includes, - Values = ["string"], + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, }, ], - MinimumAmount = "minimum_amount", - }; - string expectedMinimumAmount = "minimum_amount"; - DateTimeOffset expectedPaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - List expectedPaymentAttempts = - [ - new() + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() { - ID = "id", - Amount = "amount", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentProvider = Models::PaymentProvider.Stripe, - PaymentProviderID = "payment_provider_id", - ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", - Succeeded = true, + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", }, - ]; - DateTimeOffset expectedPaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DateTimeOffset expectedPaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DateTimeOffset expectedScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Models::Address expectedShippingAddress = new() - { - City = "city", - Country = "country", - Line1 = "line1", - Line2 = "line2", - PostalCode = "postal_code", - State = "state", + Status = Models::Status.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, }; - ApiEnum expectedStatus = Models::Status.Issued; - Models::SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); - string expectedSubtotal = "8.00"; - DateTimeOffset expectedSyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedTotal = "8.00"; - DateTimeOffset expectedVoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - bool expectedWillAutoIssue = true; - Assert.Equal(expectedID, model.ID); - Assert.Equal(expectedAmountDue, model.AmountDue); - Assert.Equal(expectedAutoCollection, model.AutoCollection); - Assert.Equal(expectedBillingAddress, model.BillingAddress); - Assert.Equal(expectedCreatedAt, model.CreatedAt); - Assert.Equal(expectedCreditNotes.Count, model.CreditNotes.Count); - for (int i = 0; i < expectedCreditNotes.Count; i++) - { - Assert.Equal(expectedCreditNotes[i], model.CreditNotes[i]); - } - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedCustomer, model.Customer); - Assert.Equal( - expectedCustomerBalanceTransactions.Count, - model.CustomerBalanceTransactions.Count + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions ); - for (int i = 0; i < expectedCustomerBalanceTransactions.Count; i++) - { - Assert.Equal( - expectedCustomerBalanceTransactions[i], - model.CustomerBalanceTransactions[i] - ); - } - Assert.Equal(expectedCustomerTaxID, model.CustomerTaxID); - Assert.True(JsonElement.DeepEquals(expectedDiscount, model.Discount)); - Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], model.Discounts[i]); - } - Assert.Equal(expectedDueDate, model.DueDate); - Assert.Equal(expectedEligibleToIssueAt, model.EligibleToIssueAt); - Assert.Equal(expectedHostedInvoiceUrl, model.HostedInvoiceUrl); - Assert.Equal(expectedInvoiceDate, model.InvoiceDate); - Assert.Equal(expectedInvoiceNumber, model.InvoiceNumber); - Assert.Equal(expectedInvoicePdf, model.InvoicePdf); - Assert.Equal(expectedInvoiceSource, model.InvoiceSource); - Assert.Equal(expectedIsPayableNow, model.IsPayableNow); - Assert.Equal(expectedIssueFailedAt, model.IssueFailedAt); - Assert.Equal(expectedIssuedAt, model.IssuedAt); - Assert.Equal(expectedLineItems.Count, model.LineItems.Count); - for (int i = 0; i < expectedLineItems.Count; i++) - { - Assert.Equal(expectedLineItems[i], model.LineItems[i]); - } - Assert.Equal(expectedMaximum, model.Maximum); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMemo, model.Memo); - 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(expectedPaidAt, model.PaidAt); - Assert.Equal(expectedPaymentAttempts.Count, model.PaymentAttempts.Count); - for (int i = 0; i < expectedPaymentAttempts.Count; i++) - { - Assert.Equal(expectedPaymentAttempts[i], model.PaymentAttempts[i]); - } - Assert.Equal(expectedPaymentFailedAt, model.PaymentFailedAt); - Assert.Equal(expectedPaymentStartedAt, model.PaymentStartedAt); - Assert.Equal(expectedScheduledIssueAt, model.ScheduledIssueAt); - Assert.Equal(expectedShippingAddress, model.ShippingAddress); - Assert.Equal(expectedStatus, model.Status); - Assert.Equal(expectedSubscription, model.Subscription); - Assert.Equal(expectedSubtotal, model.Subtotal); - Assert.Equal(expectedSyncFailedAt, model.SyncFailedAt); - Assert.Equal(expectedTotal, model.Total); - Assert.Equal(expectedVoidedAt, model.VoidedAt); - Assert.Equal(expectedWillAutoIssue, model.WillAutoIssue); + Assert.Equal(model, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void FieldRoundtripThroughSerialization_Works() { var model = new Models::CreatedInvoice { @@ -6181,778 +7374,772 @@ public void SerializationRoundtrip_Works() WillAutoIssue = true, }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( - json, + element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Models::CreatedInvoice + string expectedID = "id"; + string expectedAmountDue = "8.00"; + Models::AutoCollection expectedAutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + Models::Address expectedBillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); + List expectedCreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ]; + string expectedCurrency = "USD"; + Models::CustomerMinified expectedCustomer = new() { ID = "id", - AmountDue = "8.00", - AutoCollection = new() + ExternalCustomerID = "external_customer_id", + }; + List expectedCustomerBalanceTransactions = + [ + new() { - Enabled = true, - NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - NumAttempts = 0, - PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, }, - BillingAddress = new() + ]; + Models::CustomerTaxID expectedCustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }; + JsonElement expectedDiscount = JsonSerializer.Deserialize("{}"); + List expectedDiscounts = + [ + new Models::PercentageDiscount() { - City = "city", - Country = "country", - Line1 = "line1", - Line2 = "line2", - PostalCode = "postal_code", - State = "state", + DiscountType = Models::PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", }, - CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - CreditNotes = - [ - new() - { - ID = "id", - CreditNoteNumber = "credit_note_number", - Memo = "memo", - Reason = "reason", - Total = "total", - Type = "type", - VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - }, - ], - Currency = "USD", - Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, - CustomerBalanceTransactions = - [ - new() - { - ID = "cgZa3SXcsPTVyC4Y", - Action = Models::Action.AppliedToInvoice, - Amount = "11.00", - CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - CreditNote = new("id"), - Description = "An optional description", - EndingBalance = "22.00", - Invoice = new("gXcsPTVyC4YZa3Sc"), - StartingBalance = "33.00", - Type = Models::Type.Increment, - }, - ], - CustomerTaxID = new() + ]; + DateTimeOffset expectedDueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"); + DateTimeOffset expectedEligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedHostedInvoiceUrl = "hosted_invoice_url"; + DateTimeOffset expectedInvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"); + string expectedInvoiceNumber = "JYEFHK-00001"; + string expectedInvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb"; + ApiEnum expectedInvoiceSource = + Models::InvoiceSource.Subscription; + bool expectedIsPayableNow = true; + DateTimeOffset expectedIssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedIssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + List expectedLineItems = + [ + new() { - Country = Models::Country.Ad, - Type = Models::CustomerTaxIDType.AdNrt, - Value = "value", - }, - Discount = JsonSerializer.Deserialize("{}"), - Discounts = - [ - new Models::PercentageDiscount() + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() { - DiscountType = Models::PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = [ new() { - Field = Models::PercentageDiscountFilterField.PriceID, - Operator = Models::PercentageDiscountFilterOperator.Includes, + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, Values = ["string"], }, ], - Reason = "reason", - }, - ], - DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), - EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - HostedInvoiceUrl = "hosted_invoice_url", - InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), - InvoiceNumber = "JYEFHK-00001", - InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", - InvoiceSource = Models::InvoiceSource.Subscription, - IsPayableNow = true, - IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - LineItems = - [ - new() - { - ID = "id", - AdjustedSubtotal = "5.00", - Adjustments = - [ - new Models::MonetaryUsageDiscountAdjustment() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() { - ID = "id", - AdjustmentType = - Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, - Amount = "amount", - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = - Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, - Operator = - Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - Reason = "reason", - ReplacesAdjustmentID = "replaces_adjustment_id", - UsageDiscount = 0, + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, }, - ], - Amount = "7.00", - CreditsApplied = "6.00", - EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), - Filter = "filter", - Grouping = "grouping", - Name = "Fixed Fee", - PartiallyInvoicedAmount = "4.00", - Price = new Models::Unit() + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - BillingMode = Models::BillingMode.InAdvance, - Cadence = Models::UnitCadence.OneTime, - CompositePriceFilters = + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ new() { - Field = Models::CompositePriceFilterField.PriceID, - Operator = Models::CompositePriceFilterOperator.Includes, + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, Values = ["string"], }, ], - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = - Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], }, - Filters = - [ - new() - { - Field = Models::Field.PriceID, - Operator = Models::Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - 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", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = Models::MaximumFilterField.PriceID, - Operator = Models::MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = Models::MinimumFilterField.PriceID, - Operator = Models::MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, + ], MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = Models::UnitPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, }, - Quantity = 1, - StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), - SubLineItems = - [ - new Models::MatrixSubLineItem() - { - Amount = "9.00", - Grouping = new() { Key = "region", Value = "west" }, - MatrixConfig = new(["string"]), - Name = "Tier One", - Quantity = 5, - Type = Models::MatrixSubLineItemType.Matrix, - ScaledQuantity = 0, - }, - ], - Subtotal = "9.00", - TaxAmounts = - [ - new() - { - Amount = "amount", - TaxRateDescription = "tax_rate_description", - TaxRatePercentage = "tax_rate_percentage", - }, - ], - UsageCustomerIds = ["string"], + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, }, - ], - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = [ - new() + new Models::MatrixSubLineItem() { - Field = Models::MaximumFilterField.PriceID, - Operator = Models::MaximumFilterOperator.Includes, - Values = ["string"], + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, }, ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Memo = "memo", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = + Subtotal = "9.00", + TaxAmounts = [ new() { - Field = Models::MinimumFilterField.PriceID, - Operator = Models::MinimumFilterOperator.Includes, - Values = ["string"], + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", }, ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentAttempts = - [ - new() - { - ID = "id", - Amount = "amount", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentProvider = Models::PaymentProvider.Stripe, - PaymentProviderID = "payment_provider_id", - ReceiptPdf = - "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", - Succeeded = true, - }, - ], - PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ShippingAddress = new() - { - City = "city", - Country = "country", - Line1 = "line1", - Line2 = "line2", - PostalCode = "postal_code", - State = "state", + UsageCustomerIds = ["string"], }, - Status = Models::Status.Issued, - Subscription = new("VDGsT23osdLb84KD"), - Subtotal = "8.00", - SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - Total = "8.00", - VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - WillAutoIssue = true, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedID = "id"; - string expectedAmountDue = "8.00"; - Models::AutoCollection expectedAutoCollection = new() - { - Enabled = true, - NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - NumAttempts = 0, - PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ]; + Models::Maximum expectedMaximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", }; - Models::Address expectedBillingAddress = new() + string expectedMaximumAmount = "maximum_amount"; + string expectedMemo = "memo"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + Models::Minimum expectedMinimum = new() { - City = "city", - Country = "country", - Line1 = "line1", - Line2 = "line2", - PostalCode = "postal_code", - State = "state", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", }; - DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); - List expectedCreditNotes = + string expectedMinimumAmount = "minimum_amount"; + DateTimeOffset expectedPaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + List expectedPaymentAttempts = [ new() { ID = "id", - CreditNoteNumber = "credit_note_number", - Memo = "memo", - Reason = "reason", - Total = "total", - Type = "type", - VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, }, ]; - string expectedCurrency = "USD"; - Models::CustomerMinified expectedCustomer = new() + DateTimeOffset expectedPaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedPaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Models::Address expectedShippingAddress = new() { - ID = "id", - ExternalCustomerID = "external_customer_id", + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", }; - List expectedCustomerBalanceTransactions = - [ - new() - { - ID = "cgZa3SXcsPTVyC4Y", - Action = Models::Action.AppliedToInvoice, - Amount = "11.00", - CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), - CreditNote = new("id"), - Description = "An optional description", - EndingBalance = "22.00", - Invoice = new("gXcsPTVyC4YZa3Sc"), - StartingBalance = "33.00", - Type = Models::Type.Increment, - }, - ]; - Models::CustomerTaxID expectedCustomerTaxID = new() + ApiEnum expectedStatus = Models::Status.Issued; + Models::SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); + string expectedSubtotal = "8.00"; + DateTimeOffset expectedSyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedTotal = "8.00"; + DateTimeOffset expectedVoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + bool expectedWillAutoIssue = true; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedAmountDue, deserialized.AmountDue); + Assert.Equal(expectedAutoCollection, deserialized.AutoCollection); + Assert.Equal(expectedBillingAddress, deserialized.BillingAddress); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedCreditNotes.Count, deserialized.CreditNotes.Count); + for (int i = 0; i < expectedCreditNotes.Count; i++) { - Country = Models::Country.Ad, - Type = Models::CustomerTaxIDType.AdNrt, - Value = "value", - }; - JsonElement expectedDiscount = JsonSerializer.Deserialize("{}"); - List expectedDiscounts = - [ - new Models::PercentageDiscount() + Assert.Equal(expectedCreditNotes[i], deserialized.CreditNotes[i]); + } + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedCustomer, deserialized.Customer); + Assert.Equal( + expectedCustomerBalanceTransactions.Count, + deserialized.CustomerBalanceTransactions.Count + ); + for (int i = 0; i < expectedCustomerBalanceTransactions.Count; i++) + { + Assert.Equal( + expectedCustomerBalanceTransactions[i], + deserialized.CustomerBalanceTransactions[i] + ); + } + Assert.Equal(expectedCustomerTaxID, deserialized.CustomerTaxID); + Assert.True(JsonElement.DeepEquals(expectedDiscount, deserialized.Discount)); + Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); + } + Assert.Equal(expectedDueDate, deserialized.DueDate); + Assert.Equal(expectedEligibleToIssueAt, deserialized.EligibleToIssueAt); + Assert.Equal(expectedHostedInvoiceUrl, deserialized.HostedInvoiceUrl); + Assert.Equal(expectedInvoiceDate, deserialized.InvoiceDate); + Assert.Equal(expectedInvoiceNumber, deserialized.InvoiceNumber); + Assert.Equal(expectedInvoicePdf, deserialized.InvoicePdf); + Assert.Equal(expectedInvoiceSource, deserialized.InvoiceSource); + Assert.Equal(expectedIsPayableNow, deserialized.IsPayableNow); + Assert.Equal(expectedIssueFailedAt, deserialized.IssueFailedAt); + Assert.Equal(expectedIssuedAt, deserialized.IssuedAt); + Assert.Equal(expectedLineItems.Count, deserialized.LineItems.Count); + for (int i = 0; i < expectedLineItems.Count; i++) + { + Assert.Equal(expectedLineItems[i], deserialized.LineItems[i]); + } + Assert.Equal(expectedMaximum, deserialized.Maximum); + Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.Equal(expectedMemo, deserialized.Memo); + 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(expectedPaidAt, deserialized.PaidAt); + Assert.Equal(expectedPaymentAttempts.Count, deserialized.PaymentAttempts.Count); + for (int i = 0; i < expectedPaymentAttempts.Count; i++) + { + Assert.Equal(expectedPaymentAttempts[i], deserialized.PaymentAttempts[i]); + } + Assert.Equal(expectedPaymentFailedAt, deserialized.PaymentFailedAt); + Assert.Equal(expectedPaymentStartedAt, deserialized.PaymentStartedAt); + Assert.Equal(expectedScheduledIssueAt, deserialized.ScheduledIssueAt); + Assert.Equal(expectedShippingAddress, deserialized.ShippingAddress); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedSubscription, deserialized.Subscription); + Assert.Equal(expectedSubtotal, deserialized.Subtotal); + Assert.Equal(expectedSyncFailedAt, deserialized.SyncFailedAt); + Assert.Equal(expectedTotal, deserialized.Total); + Assert.Equal(expectedVoidedAt, deserialized.VoidedAt); + Assert.Equal(expectedWillAutoIssue, deserialized.WillAutoIssue); + } + + [Fact] + public void Validation_Works() + { + var model = new Models::CreatedInvoice + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() { - DiscountType = Models::PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = Models::PercentageDiscountFilterField.PriceID, - Operator = Models::PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }, - ]; - DateTimeOffset expectedDueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"); - DateTimeOffset expectedEligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedHostedInvoiceUrl = "hosted_invoice_url"; - DateTimeOffset expectedInvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"); - string expectedInvoiceNumber = "JYEFHK-00001"; - string expectedInvoicePdf = - "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb"; - ApiEnum expectedInvoiceSource = - Models::InvoiceSource.Subscription; - bool expectedIsPayableNow = true; - DateTimeOffset expectedIssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DateTimeOffset expectedIssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - List expectedLineItems = - [ - new() + BillingAddress = new() { - ID = "id", - AdjustedSubtotal = "5.00", - Adjustments = - [ - new Models::MonetaryUsageDiscountAdjustment() - { - ID = "id", - AdjustmentType = - Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, - Amount = "amount", - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, - Operator = - Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - Reason = "reason", - ReplacesAdjustmentID = "replaces_adjustment_id", - UsageDiscount = 0, - }, - ], - Amount = "7.00", - CreditsApplied = "6.00", - EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), - Filter = "filter", - Grouping = "grouping", - Name = "Fixed Fee", - PartiallyInvoicedAmount = "4.00", - Price = new Models::Unit() + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() { ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - BillingMode = Models::BillingMode.InAdvance, - Cadence = Models::UnitCadence.OneTime, - CompositePriceFilters = + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + new Models::PercentageDiscount() + { + DiscountType = Models::PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = [ new() { - Field = Models::CompositePriceFilterField.PriceID, - Operator = Models::CompositePriceFilterOperator.Includes, + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, Values = ["string"], }, ], - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = - Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() + Reason = "reason", + }, + ], + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceSource.Subscription, + IsPayableNow = true, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + DurationUnit = Models::DurationUnit.Day, }, - Filters = - [ - new() - { - Field = Models::Field.PriceID, - Operator = Models::Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new Models::PercentageDiscount() - { - DiscountType = Models::PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = [ new() { - Field = Models::PercentageDiscountFilterField.PriceID, - Operator = Models::PercentageDiscountFilterOperator.Includes, + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, Values = ["string"], }, ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() { - Field = Models::MaximumFilterField.PriceID, - Operator = Models::MaximumFilterOperator.Includes, - Values = ["string"], + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, }, - ], + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = Models::MinimumFilterField.PriceID, - Operator = Models::MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = Models::UnitPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], }, - Quantity = 1, - StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), - SubLineItems = + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ - new Models::MatrixSubLineItem() + new() { - Amount = "9.00", - Grouping = new() { Key = "region", Value = "west" }, - MatrixConfig = new(["string"]), - Name = "Tier One", - Quantity = 5, - Type = Models::MatrixSubLineItemType.Matrix, - ScaledQuantity = 0, + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], }, ], - Subtotal = "9.00", - TaxAmounts = + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ new() { - Amount = "amount", - TaxRateDescription = "tax_rate_description", - TaxRatePercentage = "tax_rate_percentage", + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], }, ], - UsageCustomerIds = ["string"], + MinimumAmount = "minimum_amount", }, - ]; - Models::Maximum expectedMaximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = Models::MaximumFilterField.PriceID, - Operator = Models::MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }; - string expectedMaximumAmount = "maximum_amount"; - string expectedMemo = "memo"; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - Models::Minimum expectedMinimum = new() - { - AppliesToPriceIds = ["string"], - Filters = + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = [ new() { - Field = Models::MinimumFilterField.PriceID, - Operator = Models::MinimumFilterOperator.Includes, - Values = ["string"], + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, }, ], - MinimumAmount = "minimum_amount", - }; - string expectedMinimumAmount = "minimum_amount"; - DateTimeOffset expectedPaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - List expectedPaymentAttempts = - [ - new() + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() { - ID = "id", - Amount = "amount", - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentProvider = Models::PaymentProvider.Stripe, - PaymentProviderID = "payment_provider_id", - ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", - Succeeded = true, + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", }, - ]; - DateTimeOffset expectedPaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DateTimeOffset expectedPaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - DateTimeOffset expectedScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Models::Address expectedShippingAddress = new() - { - City = "city", - Country = "country", - Line1 = "line1", - Line2 = "line2", - PostalCode = "postal_code", - State = "state", - }; - ApiEnum expectedStatus = Models::Status.Issued; - Models::SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); - string expectedSubtotal = "8.00"; - DateTimeOffset expectedSyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedTotal = "8.00"; - DateTimeOffset expectedVoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - bool expectedWillAutoIssue = true; - - Assert.Equal(expectedID, deserialized.ID); - Assert.Equal(expectedAmountDue, deserialized.AmountDue); - Assert.Equal(expectedAutoCollection, deserialized.AutoCollection); - Assert.Equal(expectedBillingAddress, deserialized.BillingAddress); - Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); - Assert.Equal(expectedCreditNotes.Count, deserialized.CreditNotes.Count); - for (int i = 0; i < expectedCreditNotes.Count; i++) - { - Assert.Equal(expectedCreditNotes[i], deserialized.CreditNotes[i]); - } - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal(expectedCustomer, deserialized.Customer); - Assert.Equal( - expectedCustomerBalanceTransactions.Count, - deserialized.CustomerBalanceTransactions.Count - ); - for (int i = 0; i < expectedCustomerBalanceTransactions.Count; i++) - { - Assert.Equal( - expectedCustomerBalanceTransactions[i], - deserialized.CustomerBalanceTransactions[i] - ); - } - Assert.Equal(expectedCustomerTaxID, deserialized.CustomerTaxID); - Assert.True(JsonElement.DeepEquals(expectedDiscount, deserialized.Discount)); - Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); - } - Assert.Equal(expectedDueDate, deserialized.DueDate); - Assert.Equal(expectedEligibleToIssueAt, deserialized.EligibleToIssueAt); - Assert.Equal(expectedHostedInvoiceUrl, deserialized.HostedInvoiceUrl); - Assert.Equal(expectedInvoiceDate, deserialized.InvoiceDate); - Assert.Equal(expectedInvoiceNumber, deserialized.InvoiceNumber); - Assert.Equal(expectedInvoicePdf, deserialized.InvoicePdf); - Assert.Equal(expectedInvoiceSource, deserialized.InvoiceSource); - Assert.Equal(expectedIsPayableNow, deserialized.IsPayableNow); - Assert.Equal(expectedIssueFailedAt, deserialized.IssueFailedAt); - Assert.Equal(expectedIssuedAt, deserialized.IssuedAt); - Assert.Equal(expectedLineItems.Count, deserialized.LineItems.Count); - for (int i = 0; i < expectedLineItems.Count; i++) - { - Assert.Equal(expectedLineItems[i], deserialized.LineItems[i]); - } - Assert.Equal(expectedMaximum, deserialized.Maximum); - Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); - Assert.Equal(expectedMemo, deserialized.Memo); - 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(expectedPaidAt, deserialized.PaidAt); - Assert.Equal(expectedPaymentAttempts.Count, deserialized.PaymentAttempts.Count); - for (int i = 0; i < expectedPaymentAttempts.Count; i++) - { - Assert.Equal(expectedPaymentAttempts[i], deserialized.PaymentAttempts[i]); - } - Assert.Equal(expectedPaymentFailedAt, deserialized.PaymentFailedAt); - Assert.Equal(expectedPaymentStartedAt, deserialized.PaymentStartedAt); - Assert.Equal(expectedScheduledIssueAt, deserialized.ScheduledIssueAt); - Assert.Equal(expectedShippingAddress, deserialized.ShippingAddress); - Assert.Equal(expectedStatus, deserialized.Status); - Assert.Equal(expectedSubscription, deserialized.Subscription); - Assert.Equal(expectedSubtotal, deserialized.Subtotal); - Assert.Equal(expectedSyncFailedAt, deserialized.SyncFailedAt); - Assert.Equal(expectedTotal, deserialized.Total); - Assert.Equal(expectedVoidedAt, deserialized.VoidedAt); - Assert.Equal(expectedWillAutoIssue, deserialized.WillAutoIssue); + Status = Models::Status.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { var model = new Models::CreatedInvoice { @@ -7291,7 +8478,9 @@ public void Validation_Works() WillAutoIssue = true, }; - model.Validate(); + Models::CreatedInvoice copied = new(model); + + Assert.Equal(model, copied); } } @@ -7385,6 +8574,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Models::AutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Models::AutoCollection copied = new(model); + + Assert.Equal(model, copied); + } } public class CreditNoteTest : TestBase @@ -7497,6 +8702,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Models::CreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + Models::CreditNote copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerBalanceTransactionTest : TestBase @@ -7633,6 +8857,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Models::CustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }; + + Models::CustomerBalanceTransaction copied = new(model); + + Assert.Equal(model, copied); + } } public class ActionTest : TestBase @@ -8989,6 +10235,192 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Models::LineItem + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }; + + Models::LineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class LineItemAdjustmentTest : TestBase @@ -9523,6 +10955,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Models::PaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }; + + Models::PaymentAttempt copied = new(model); + + Assert.Equal(model, copied); + } } public class PaymentProviderTest : TestBase diff --git a/src/Orb.Tests/Models/ConversionRateTierTest.cs b/src/Orb.Tests/Models/ConversionRateTierTest.cs index 8e6addb47..39d84035c 100644 --- a/src/Orb.Tests/Models/ConversionRateTierTest.cs +++ b/src/Orb.Tests/Models/ConversionRateTierTest.cs @@ -128,4 +128,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ConversionRateTier + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }; + + ConversionRateTier copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/ConversionRateTieredConfigTest.cs b/src/Orb.Tests/Models/ConversionRateTieredConfigTest.cs index 00a9ab90b..5eda54785 100644 --- a/src/Orb.Tests/Models/ConversionRateTieredConfigTest.cs +++ b/src/Orb.Tests/Models/ConversionRateTieredConfigTest.cs @@ -123,4 +123,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ConversionRateTieredConfig + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + }; + + ConversionRateTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/ConversionRateUnitConfigTest.cs b/src/Orb.Tests/Models/ConversionRateUnitConfigTest.cs index 561cd9501..e49f80cd7 100644 --- a/src/Orb.Tests/Models/ConversionRateUnitConfigTest.cs +++ b/src/Orb.Tests/Models/ConversionRateUnitConfigTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ConversionRateUnitConfig { UnitAmount = "unit_amount" }; + + ConversionRateUnitConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/CouponRedemptionTest.cs b/src/Orb.Tests/Models/CouponRedemptionTest.cs index 5fac7de63..13e2538d0 100644 --- a/src/Orb.Tests/Models/CouponRedemptionTest.cs +++ b/src/Orb.Tests/Models/CouponRedemptionTest.cs @@ -83,4 +83,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CouponRedemption + { + CouponID = "coupon_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + CouponRedemption copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs b/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs index 8a98bf6f6..9d0f61f05 100644 --- a/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs @@ -190,6 +190,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Percentage { PercentageDiscount = 0 }; + + Percentage copied = new(model); + + Assert.Equal(model, copied); + } } public class AmountTest : TestBase @@ -240,4 +250,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Amount { AmountDiscount = "amount_discount" }; + + Amount copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Coupons/CouponListPageResponseTest.cs b/src/Orb.Tests/Models/Coupons/CouponListPageResponseTest.cs index a4ced98f5..cee206e37 100644 --- a/src/Orb.Tests/Models/Coupons/CouponListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponListPageResponseTest.cs @@ -255,4 +255,45 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CouponListPageResponse + { + Data = + [ + new() + { + ID = "7iz2yanVjQoBZhyH", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + DurationInMonths = 12, + MaxRedemptions = 0, + RedemptionCode = "HALFOFF", + TimesRedeemed = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + CouponListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Coupons/CouponTest.cs b/src/Orb.Tests/Models/Coupons/CouponTest.cs index 45c1710d2..2c8d1be18 100644 --- a/src/Orb.Tests/Models/Coupons/CouponTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponTest.cs @@ -200,6 +200,40 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Coupon + { + ID = "7iz2yanVjQoBZhyH", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + DurationInMonths = 12, + MaxRedemptions = 0, + RedemptionCode = "HALFOFF", + TimesRedeemed = 0, + }; + + Coupon copied = new(model); + + Assert.Equal(model, copied); + } } public class CouponDiscountTest : TestBase diff --git a/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs b/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs index 260a03ebd..f074b2ee6 100644 --- a/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs @@ -181,6 +181,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditBlockRetrieveResponse + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + PerUnitCostBasis = "per_unit_cost_basis", + Status = Status.Active, + }; + + CreditBlockRetrieveResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -263,6 +291,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class FieldTest : TestBase diff --git a/src/Orb.Tests/Models/CreditNoteTinyTest.cs b/src/Orb.Tests/Models/CreditNoteTinyTest.cs index 3b96ad9df..4a3d7fc88 100644 --- a/src/Orb.Tests/Models/CreditNoteTinyTest.cs +++ b/src/Orb.Tests/Models/CreditNoteTinyTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditNoteTiny { ID = "id" }; + + CreditNoteTiny copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs b/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs index 052af5b34..fed689221 100644 --- a/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs +++ b/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs @@ -297,6 +297,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LineItem + { + Amount = "amount", + InvoiceLineItemID = "4khy3nwzktxv7", + EndDate = "2023-09-22", + StartDate = "2023-09-22", + }; + + LineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class ReasonTest : TestBase diff --git a/src/Orb.Tests/Models/CreditNotes/CreditNoteListPageResponseTest.cs b/src/Orb.Tests/Models/CreditNotes/CreditNoteListPageResponseTest.cs index eed057389..1a427bc51 100644 --- a/src/Orb.Tests/Models/CreditNotes/CreditNoteListPageResponseTest.cs +++ b/src/Orb.Tests/Models/CreditNotes/CreditNoteListPageResponseTest.cs @@ -531,4 +531,91 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditNoteListPageResponse + { + Data = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartTimeInclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + CreditNoteListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/CustomExpirationTest.cs b/src/Orb.Tests/Models/CustomExpirationTest.cs index c699aaf7e..813cf275e 100644 --- a/src/Orb.Tests/Models/CustomExpirationTest.cs +++ b/src/Orb.Tests/Models/CustomExpirationTest.cs @@ -77,6 +77,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomExpiration + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }; + + CustomExpiration copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomExpirationDurationUnitTest : TestBase diff --git a/src/Orb.Tests/Models/CustomerMinifiedTest.cs b/src/Orb.Tests/Models/CustomerMinifiedTest.cs index a77ba86f8..2f3e91690 100644 --- a/src/Orb.Tests/Models/CustomerMinifiedTest.cs +++ b/src/Orb.Tests/Models/CustomerMinifiedTest.cs @@ -58,4 +58,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerMinified { ID = "id", ExternalCustomerID = "external_customer_id" }; + + CustomerMinified copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/CustomerTaxIDTest.cs b/src/Orb.Tests/Models/CustomerTaxIDTest.cs index 1d2123df2..11f10dfe3 100644 --- a/src/Orb.Tests/Models/CustomerTaxIDTest.cs +++ b/src/Orb.Tests/Models/CustomerTaxIDTest.cs @@ -83,6 +83,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerTaxID + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }; + + CustomerTaxID copied = new(model); + + Assert.Equal(model, copied); + } } public class CountryTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs b/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs index e82731e88..64734d24f 100644 --- a/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs +++ b/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs @@ -74,4 +74,18 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AccountingProviderConfig + { + ExternalProviderID = "external_provider_id", + ProviderType = "provider_type", + }; + + AccountingProviderConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/AddressInputTest.cs b/src/Orb.Tests/Models/Customers/AddressInputTest.cs index bc5280aa1..8b51c33e7 100644 --- a/src/Orb.Tests/Models/Customers/AddressInputTest.cs +++ b/src/Orb.Tests/Models/Customers/AddressInputTest.cs @@ -176,4 +176,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AddressInput + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + + AddressInput copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponseTest.cs b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponseTest.cs index 6fd0efbf2..25c76f33c 100644 --- a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponseTest.cs @@ -147,6 +147,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BalanceTransactions::BalanceTransactionCreateResponse + { + ID = "cgZa3SXcsPTVyC4Y", + Action = BalanceTransactions::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = BalanceTransactions::BalanceTransactionCreateResponseType.Increment, + }; + + BalanceTransactions::BalanceTransactionCreateResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class ActionTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponseTest.cs b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponseTest.cs index eb6996317..c5c9fd38d 100644 --- a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponseTest.cs @@ -183,4 +183,33 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BalanceTransactionListPageResponse + { + Data = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = BalanceTransactionListResponseAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = BalanceTransactionListResponseType.Increment, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + BalanceTransactionListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListResponseTest.cs b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListResponseTest.cs index dbaaeaa02..85b6c0baf 100644 --- a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListResponseTest.cs @@ -145,6 +145,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BalanceTransactionListResponse + { + ID = "cgZa3SXcsPTVyC4Y", + Action = BalanceTransactionListResponseAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = BalanceTransactionListResponseType.Increment, + }; + + BalanceTransactionListResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class BalanceTransactionListResponseActionTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs index 173628e43..24478306c 100644 --- a/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs @@ -875,4 +875,150 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CostListByExternalIDResponse + { + Data = + [ + new() + { + PerPriceCosts = + [ + new() + { + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + PriceID = "price_id", + Subtotal = "subtotal", + Total = "total", + Quantity = 0, + }, + ], + Subtotal = "subtotal", + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "total", + }, + ], + }; + + CostListByExternalIDResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs b/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs index dc2b23106..e7e762d50 100644 --- a/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs @@ -875,4 +875,150 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CostListResponse + { + Data = + [ + new() + { + PerPriceCosts = + [ + new() + { + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + PriceID = "price_id", + Subtotal = "subtotal", + Total = "total", + Quantity = 0, + }, + ], + Subtotal = "subtotal", + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "total", + }, + ], + }; + + CostListResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDPageResponseTest.cs index 17ad78f93..74934f36f 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDPageResponseTest.cs @@ -219,4 +219,39 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditListByExternalIDPageResponse + { + Data = + [ + new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = CreditListByExternalIDResponseFilterField.ItemID, + Operator = CreditListByExternalIDResponseFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + PerUnitCostBasis = "per_unit_cost_basis", + Status = CreditListByExternalIDResponseStatus.Active, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + CreditListByExternalIDPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs index 93d1e1994..22aa24df6 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs @@ -183,6 +183,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditListByExternalIDResponse + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = CreditListByExternalIDResponseFilterField.ItemID, + Operator = CreditListByExternalIDResponseFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + PerUnitCostBasis = "per_unit_cost_basis", + Status = CreditListByExternalIDResponseStatus.Active, + }; + + CreditListByExternalIDResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class CreditListByExternalIDResponseFilterTest : TestBase @@ -275,6 +303,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditListByExternalIDResponseFilter + { + Field = CreditListByExternalIDResponseFilterField.ItemID, + Operator = CreditListByExternalIDResponseFilterOperator.Includes, + Values = ["string"], + }; + + CreditListByExternalIDResponseFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class CreditListByExternalIDResponseFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListPageResponseTest.cs index fd73f229c..0c0cf689b 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListPageResponseTest.cs @@ -219,4 +219,39 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditListPageResponse + { + Data = + [ + new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Field.ItemID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + PerUnitCostBasis = "per_unit_cost_basis", + Status = Status.Active, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + CreditListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs index f27809e6f..e1d4930a5 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs @@ -181,6 +181,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditListResponse + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Field.ItemID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + PerUnitCostBasis = "per_unit_cost_basis", + Status = Status.Active, + }; + + CreditListResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -263,6 +291,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter + { + Field = Field.ItemID, + Operator = Operator.Includes, + Values = ["string"], + }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class FieldTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/AffectedBlockTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/AffectedBlockTest.cs index fb763049b..546f20a2c 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/AffectedBlockTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/AffectedBlockTest.cs @@ -149,6 +149,30 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AffectedBlock + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }; + + AffectedBlock copied = new(model); + + Assert.Equal(model, copied); + } } public class AffectedBlockFilterTest : TestBase @@ -239,6 +263,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AffectedBlockFilter + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }; + + AffectedBlockFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class AffectedBlockFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/AmendmentLedgerEntryTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/AmendmentLedgerEntryTest.cs index 9d2c202b1..4b8880c79 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/AmendmentLedgerEntryTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/AmendmentLedgerEntryTest.cs @@ -274,6 +274,45 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AmendmentLedgerEntry + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = AmendmentLedgerEntryEntryStatus.Committed, + EntryType = AmendmentLedgerEntryEntryType.Amendment, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + StartingBalance = 0, + }; + + AmendmentLedgerEntry copied = new(model); + + Assert.Equal(model, copied); + } } public class AmendmentLedgerEntryEntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntryTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntryTest.cs index b73105353..0abb6fc6e 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntryTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntryTest.cs @@ -274,6 +274,45 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditBlockExpiryLedgerEntry + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = CreditBlockExpiryLedgerEntryEntryStatus.Committed, + EntryType = CreditBlockExpiryLedgerEntryEntryType.CreditBlockExpiry, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + StartingBalance = 0, + }; + + CreditBlockExpiryLedgerEntry copied = new(model); + + Assert.Equal(model, copied); + } } public class CreditBlockExpiryLedgerEntryEntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/DecrementLedgerEntryTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/DecrementLedgerEntryTest.cs index 9186fdfc9..857c9180b 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/DecrementLedgerEntryTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/DecrementLedgerEntryTest.cs @@ -464,6 +464,48 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DecrementLedgerEntry + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = DecrementLedgerEntryEntryStatus.Committed, + EntryType = DecrementLedgerEntryEntryType.Decrement, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + StartingBalance = 0, + EventID = "event_id", + InvoiceID = "invoice_id", + PriceID = "price_id", + }; + + DecrementLedgerEntry copied = new(model); + + Assert.Equal(model, copied); + } } public class DecrementLedgerEntryEntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntryTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntryTest.cs index f74c70866..38b96fb03 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntryTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntryTest.cs @@ -286,6 +286,46 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ExpirationChangeLedgerEntry + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = ExpirationChangeLedgerEntryEntryStatus.Committed, + EntryType = ExpirationChangeLedgerEntryEntryType.ExpirationChange, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + NewBlockExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartingBalance = 0, + }; + + ExpirationChangeLedgerEntry copied = new(model); + + Assert.Equal(model, copied); + } } public class ExpirationChangeLedgerEntryEntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/IncrementLedgerEntryTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/IncrementLedgerEntryTest.cs index 013d78a0d..dd005a589 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/IncrementLedgerEntryTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/IncrementLedgerEntryTest.cs @@ -2486,6 +2486,387 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new IncrementLedgerEntry + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = IncrementLedgerEntryEntryStatus.Committed, + EntryType = IncrementLedgerEntryEntryType.Increment, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + StartingBalance = 0, + CreatedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + Models::InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + }; + + IncrementLedgerEntry copied = new(model); + + Assert.Equal(model, copied); + } } public class IncrementLedgerEntryEntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs index 03ea7b755..756454584 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs @@ -757,6 +757,45 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + LedgerCreateEntryByExternalIDParamsBodyIncrement copied = new(model); + + Assert.Equal(model, copied); + } } public class LedgerCreateEntryByExternalIDParamsBodyIncrementFilterTest : TestBase @@ -857,6 +896,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementFilter + { + Field = LedgerCreateEntryByExternalIDParamsBodyIncrementFilterField.ItemID, + Operator = LedgerCreateEntryByExternalIDParamsBodyIncrementFilterOperator.Includes, + Values = ["string"], + }; + + LedgerCreateEntryByExternalIDParamsBodyIncrementFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class LedgerCreateEntryByExternalIDParamsBodyIncrementFilterFieldTest : TestBase @@ -1243,6 +1297,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings + { + AutoCollection = true, + CustomDueDate = "2019-12-27", + InvoiceDate = "2019-12-27", + ItemID = "item_id", + Memo = "memo", + NetTerms = 0, + RequireSuccessfulPayment = true, + }; + + LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings copied = new(model); + + Assert.Equal(model, copied); + } } public class LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsCustomDueDateTest @@ -1507,6 +1580,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LedgerCreateEntryByExternalIDParamsBodyDecrement + { + Amount = 0, + Currency = "currency", + Description = "description", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + LedgerCreateEntryByExternalIDParamsBodyDecrement copied = new(model); + + Assert.Equal(model, copied); + } } public class LedgerCreateEntryByExternalIDParamsBodyExpirationChangeTest : TestBase @@ -1719,6 +1808,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LedgerCreateEntryByExternalIDParamsBodyExpirationChange + { + TargetExpiryDate = "2019-12-27", + Amount = 0, + BlockID = "block_id", + Currency = "currency", + Description = "description", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + LedgerCreateEntryByExternalIDParamsBodyExpirationChange copied = new(model); + + Assert.Equal(model, copied); + } } public class LedgerCreateEntryByExternalIDParamsBodyVoidTest : TestBase @@ -1915,6 +2023,24 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LedgerCreateEntryByExternalIDParamsBodyVoid + { + Amount = 0, + BlockID = "block_id", + Currency = "currency", + Description = "description", + Metadata = new Dictionary() { { "foo", "string" } }, + VoidReason = LedgerCreateEntryByExternalIDParamsBodyVoidVoidReason.Refund, + }; + + LedgerCreateEntryByExternalIDParamsBodyVoid copied = new(model); + + Assert.Equal(model, copied); + } } public class LedgerCreateEntryByExternalIDParamsBodyVoidVoidReasonTest : TestBase @@ -2151,4 +2277,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LedgerCreateEntryByExternalIDParamsBodyAmendment + { + Amount = 0, + BlockID = "block_id", + Currency = "currency", + Description = "description", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + LedgerCreateEntryByExternalIDParamsBodyAmendment copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs index 0128774fe..37290cb1a 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs @@ -730,6 +730,44 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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::Increment copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -818,6 +856,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Ledger::Filter + { + Field = Ledger::Field.ItemID, + Operator = Ledger::Operator.Includes, + Values = ["string"], + }; + + Ledger::Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class FieldTest : TestBase @@ -1194,6 +1247,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Ledger::InvoiceSettings + { + AutoCollection = true, + CustomDueDate = "2019-12-27", + InvoiceDate = "2019-12-27", + ItemID = "item_id", + Memo = "memo", + NetTerms = 0, + RequireSuccessfulPayment = true, + }; + + Ledger::InvoiceSettings copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomDueDateTest : TestBase @@ -1442,6 +1514,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Ledger::Decrement + { + Amount = 0, + Currency = "currency", + Description = "description", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Ledger::Decrement copied = new(model); + + Assert.Equal(model, copied); + } } public class ExpirationChangeTest : TestBase @@ -1646,6 +1734,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Ledger::ExpirationChange + { + TargetExpiryDate = "2019-12-27", + Amount = 0, + BlockID = "block_id", + Currency = "currency", + Description = "description", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Ledger::ExpirationChange copied = new(model); + + Assert.Equal(model, copied); + } } public class VoidTest : TestBase @@ -1832,6 +1939,24 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Ledger::Void + { + Amount = 0, + BlockID = "block_id", + Currency = "currency", + Description = "description", + Metadata = new Dictionary() { { "foo", "string" } }, + VoidReason = Ledger::VoidReason.Refund, + }; + + Ledger::Void copied = new(model); + + Assert.Equal(model, copied); + } } public class VoidReasonTest : TestBase @@ -2060,4 +2185,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Ledger::Amendment + { + Amount = 0, + BlockID = "block_id", + Currency = "currency", + Description = "description", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Ledger::Amendment copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponseTest.cs index f72ba1727..d86e60ef3 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponseTest.cs @@ -2485,4 +2485,420 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LedgerListByExternalIDPageResponse + { + Data = + [ + new IncrementLedgerEntry() + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = IncrementLedgerEntryEntryStatus.Committed, + EntryType = IncrementLedgerEntryEntryType.Increment, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + StartingBalance = 0, + CreatedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + Models::InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = + Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = + Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = + Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + Models::InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + LedgerListByExternalIDPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListPageResponseTest.cs index 081def1fe..8d8a04899 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListPageResponseTest.cs @@ -2485,4 +2485,420 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LedgerListPageResponse + { + Data = + [ + new IncrementLedgerEntry() + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = IncrementLedgerEntryEntryStatus.Committed, + EntryType = IncrementLedgerEntryEntryType.Increment, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + StartingBalance = 0, + CreatedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + Models::InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = + Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = + Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = + Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + Models::InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + LedgerListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntryTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntryTest.cs index fdcefd76a..6638957bd 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntryTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntryTest.cs @@ -302,6 +302,48 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VoidInitiatedLedgerEntry + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = VoidInitiatedLedgerEntryEntryStatus.Committed, + EntryType = VoidInitiatedLedgerEntryEntryType.VoidInitiated, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + NewBlockExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartingBalance = 0, + VoidAmount = 0, + VoidReason = "void_reason", + }; + + VoidInitiatedLedgerEntry copied = new(model); + + Assert.Equal(model, copied); + } } public class VoidInitiatedLedgerEntryEntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/VoidLedgerEntryTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/VoidLedgerEntryTest.cs index 34d9992d4..935df84f9 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/VoidLedgerEntryTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/VoidLedgerEntryTest.cs @@ -288,6 +288,47 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VoidLedgerEntry + { + ID = "id", + Amount = 0, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditBlock = new() + { + ID = "id", + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AffectedBlockFilterField.PriceID, + Operator = AffectedBlockFilterOperator.Includes, + Values = ["string"], + }, + ], + PerUnitCostBasis = "per_unit_cost_basis", + }, + Currency = "currency", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + Description = "description", + EndingBalance = 0, + EntryStatus = VoidLedgerEntryEntryStatus.Committed, + EntryType = VoidLedgerEntryEntryType.Void, + LedgerSequenceNumber = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + StartingBalance = 0, + VoidAmount = 0, + VoidReason = "void_reason", + }; + + VoidLedgerEntry copied = new(model); + + Assert.Equal(model, copied); + } } public class VoidLedgerEntryEntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs index 14bad1227..c2d410fce 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs @@ -377,6 +377,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUpCreateByExternalIDParamsInvoiceSettings + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }; + + TopUpCreateByExternalIDParamsInvoiceSettings copied = new(model); + + Assert.Equal(model, copied); + } } public class TopUpCreateByExternalIDParamsExpiresAfterUnitTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponseTest.cs index b7b5c01d7..61c94061b 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponseTest.cs @@ -261,6 +261,32 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUpCreateByExternalIDResponse + { + ID = "id", + Amount = "amount", + Currency = "currency", + InvoiceSettings = new() + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }, + PerUnitCostBasis = "per_unit_cost_basis", + Threshold = "threshold", + ExpiresAfter = 0, + ExpiresAfterUnit = TopUpCreateByExternalIDResponseExpiresAfterUnit.Day, + }; + + TopUpCreateByExternalIDResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class TopUpCreateByExternalIDResponseExpiresAfterUnitTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs index 3d36144c9..d91ba60ad 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs @@ -374,6 +374,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceSettings + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }; + + InvoiceSettings copied = new(model); + + Assert.Equal(model, copied); + } } public class ExpiresAfterUnitTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateResponseTest.cs index b51d41e62..063e8f680 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateResponseTest.cs @@ -261,6 +261,32 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUpCreateResponse + { + ID = "id", + Amount = "amount", + Currency = "currency", + InvoiceSettings = new() + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }, + PerUnitCostBasis = "per_unit_cost_basis", + Threshold = "threshold", + ExpiresAfter = 0, + ExpiresAfterUnit = TopUpCreateResponseExpiresAfterUnit.Day, + }; + + TopUpCreateResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class TopUpCreateResponseExpiresAfterUnitTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpInvoiceSettingsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpInvoiceSettingsTest.cs index 0266d67b8..9f9f3056c 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpInvoiceSettingsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpInvoiceSettingsTest.cs @@ -208,4 +208,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUpInvoiceSettings + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }; + + TopUpInvoiceSettings copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponseTest.cs index d74a693f4..f8a26d817 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponseTest.cs @@ -206,4 +206,37 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUpListByExternalIDPageResponse + { + Data = + [ + new() + { + ID = "id", + Amount = "amount", + Currency = "currency", + InvoiceSettings = new() + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }, + PerUnitCostBasis = "per_unit_cost_basis", + Threshold = "threshold", + ExpiresAfter = 0, + ExpiresAfterUnit = TopUpListByExternalIDResponseExpiresAfterUnit.Day, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + TopUpListByExternalIDPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponseTest.cs index 28a99b06a..4ff2b5a5f 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponseTest.cs @@ -261,6 +261,32 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUpListByExternalIDResponse + { + ID = "id", + Amount = "amount", + Currency = "currency", + InvoiceSettings = new() + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }, + PerUnitCostBasis = "per_unit_cost_basis", + Threshold = "threshold", + ExpiresAfter = 0, + ExpiresAfterUnit = TopUpListByExternalIDResponseExpiresAfterUnit.Day, + }; + + TopUpListByExternalIDResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class TopUpListByExternalIDResponseExpiresAfterUnitTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListPageResponseTest.cs index 744a85682..4baa8d2fe 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListPageResponseTest.cs @@ -206,4 +206,37 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUpListPageResponse + { + Data = + [ + new() + { + ID = "id", + Amount = "amount", + Currency = "currency", + InvoiceSettings = new() + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }, + PerUnitCostBasis = "per_unit_cost_basis", + Threshold = "threshold", + ExpiresAfter = 0, + ExpiresAfterUnit = TopUpListResponseExpiresAfterUnit.Day, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + TopUpListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListResponseTest.cs index 7c8c56676..f159c4e35 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListResponseTest.cs @@ -261,6 +261,32 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUpListResponse + { + ID = "id", + Amount = "amount", + Currency = "currency", + InvoiceSettings = new() + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }, + PerUnitCostBasis = "per_unit_cost_basis", + Threshold = "threshold", + ExpiresAfter = 0, + ExpiresAfterUnit = TopUpListResponseExpiresAfterUnit.Day, + }; + + TopUpListResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class TopUpListResponseExpiresAfterUnitTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs index 18e20a11e..9ebd2ead7 100644 --- a/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs @@ -549,6 +549,26 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = ProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + PaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class PaymentProviderTest : TestBase @@ -689,6 +709,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PaymentProvider + { + ProviderType = ProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + PaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class ProviderTypeTest : TestBase @@ -1061,6 +1095,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Numeral { TaxExempt = true, AutomaticTaxEnabled = true }; + + Numeral copied = new(model); + + Assert.Equal(model, copied); + } } public class AnrokTest : TestBase @@ -1159,6 +1203,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Anrok { TaxExempt = true, AutomaticTaxEnabled = true }; + + Anrok copied = new(model); + + Assert.Equal(model, copied); + } } public class StripeTest : TestBase @@ -1257,4 +1311,14 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Stripe { TaxExempt = true, AutomaticTaxEnabled = true }; + + Stripe copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerHierarchyConfigTest.cs b/src/Orb.Tests/Models/Customers/CustomerHierarchyConfigTest.cs index 0e16b8232..87898a923 100644 --- a/src/Orb.Tests/Models/Customers/CustomerHierarchyConfigTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerHierarchyConfigTest.cs @@ -175,4 +175,18 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerHierarchyConfig + { + ChildCustomerIds = ["string"], + ParentCustomerID = "parent_customer_id", + }; + + CustomerHierarchyConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerListPageResponseTest.cs b/src/Orb.Tests/Models/Customers/CustomerListPageResponseTest.cs index 5a3dd3781..97a2802d9 100644 --- a/src/Orb.Tests/Models/Customers/CustomerListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerListPageResponseTest.cs @@ -567,4 +567,98 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerListPageResponse + { + Data = + [ + new() + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = + [ + new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + ], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + CustomerListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerTest.cs b/src/Orb.Tests/Models/Customers/CustomerTest.cs index 10c08749c..2b76efe07 100644 --- a/src/Orb.Tests/Models/Customers/CustomerTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerTest.cs @@ -809,6 +809,90 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Customer + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = [new() { ID = "id", ExternalCustomerID = "external_customer_id" }], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }; + + Customer copied = new(model); + + Assert.Equal(model, copied); + } } public class HierarchyTest : TestBase @@ -900,6 +984,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Hierarchy + { + Children = [new() { ID = "id", ExternalCustomerID = "external_customer_id" }], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }; + + Hierarchy copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerPaymentProviderTest : TestBase @@ -1086,6 +1184,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AccountingSyncConfiguration + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }; + + AccountingSyncConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class AccountingProviderTest : TestBase @@ -1160,6 +1279,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AccountingProvider + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }; + + AccountingProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class AccountingProviderProviderTypeTest : TestBase @@ -1374,6 +1507,26 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerPaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + CustomerPaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerPaymentConfigurationPaymentProviderTest : TestBase @@ -1526,6 +1679,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + CustomerPaymentConfigurationPaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerPaymentConfigurationPaymentProviderProviderTypeTest : TestBase @@ -1632,4 +1799,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReportingConfiguration { Exempt = true }; + + ReportingConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs index fac4b6611..292dfd2ee 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs @@ -578,6 +578,27 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateByExternalIDParamsPaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + CustomerUpdateByExternalIDParamsPaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderTest : TestBase @@ -742,6 +763,21 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderTypeTest @@ -1202,6 +1238,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateByExternalIDParamsTaxConfigurationNumeral + { + TaxExempt = true, + AutomaticTaxEnabled = true, + }; + + CustomerUpdateByExternalIDParamsTaxConfigurationNumeral copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateByExternalIDParamsTaxConfigurationAnrokTest : TestBase @@ -1324,6 +1374,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateByExternalIDParamsTaxConfigurationAnrok + { + TaxExempt = true, + AutomaticTaxEnabled = true, + }; + + CustomerUpdateByExternalIDParamsTaxConfigurationAnrok copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateByExternalIDParamsTaxConfigurationStripeTest : TestBase @@ -1446,4 +1510,18 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateByExternalIDParamsTaxConfigurationStripe + { + TaxExempt = true, + AutomaticTaxEnabled = true, + }; + + CustomerUpdateByExternalIDParamsTaxConfigurationStripe copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs index 42a77ed14..f92ad46c0 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs @@ -571,6 +571,27 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateParamsPaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + CustomerUpdateParamsPaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateParamsPaymentConfigurationPaymentProviderTest : TestBase @@ -735,6 +756,21 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + CustomerUpdateParamsPaymentConfigurationPaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderTypeTest : TestBase @@ -1156,6 +1192,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateParamsTaxConfigurationNumeral + { + TaxExempt = true, + AutomaticTaxEnabled = true, + }; + + CustomerUpdateParamsTaxConfigurationNumeral copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateParamsTaxConfigurationAnrokTest : TestBase @@ -1276,6 +1326,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateParamsTaxConfigurationAnrok + { + TaxExempt = true, + AutomaticTaxEnabled = true, + }; + + CustomerUpdateParamsTaxConfigurationAnrok copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateParamsTaxConfigurationStripeTest : TestBase @@ -1396,4 +1460,18 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateParamsTaxConfigurationStripe + { + TaxExempt = true, + AutomaticTaxEnabled = true, + }; + + CustomerUpdateParamsTaxConfigurationStripe copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/NewAccountingSyncConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewAccountingSyncConfigurationTest.cs index 90901aa01..a965d634d 100644 --- a/src/Orb.Tests/Models/Customers/NewAccountingSyncConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewAccountingSyncConfigurationTest.cs @@ -165,4 +165,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewAccountingSyncConfiguration + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = "provider_type", + }, + ], + Excluded = true, + }; + + NewAccountingSyncConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/NewAvalaraTaxConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewAvalaraTaxConfigurationTest.cs index 6a7958ef2..b541dd986 100644 --- a/src/Orb.Tests/Models/Customers/NewAvalaraTaxConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewAvalaraTaxConfigurationTest.cs @@ -151,6 +151,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewAvalaraTaxConfiguration + { + TaxExempt = true, + TaxProvider = TaxProvider.Avalara, + AutomaticTaxEnabled = true, + TaxExemptionCode = "tax_exemption_code", + }; + + NewAvalaraTaxConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class TaxProviderTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/NewReportingConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewReportingConfigurationTest.cs index 7e2685ae5..831882841 100644 --- a/src/Orb.Tests/Models/Customers/NewReportingConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewReportingConfigurationTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewReportingConfiguration { Exempt = true }; + + NewReportingConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/NewSphereConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewSphereConfigurationTest.cs index 2036ae1af..698f44929 100644 --- a/src/Orb.Tests/Models/Customers/NewSphereConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewSphereConfigurationTest.cs @@ -139,6 +139,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewSphereConfiguration + { + TaxExempt = true, + TaxProvider = NewSphereConfigurationTaxProvider.Sphere, + AutomaticTaxEnabled = true, + }; + + NewSphereConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSphereConfigurationTaxProviderTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/NewTaxJarConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewTaxJarConfigurationTest.cs index 944681017..7bf14cfc2 100644 --- a/src/Orb.Tests/Models/Customers/NewTaxJarConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewTaxJarConfigurationTest.cs @@ -139,6 +139,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewTaxJarConfiguration + { + TaxExempt = true, + TaxProvider = NewTaxJarConfigurationTaxProvider.Taxjar, + AutomaticTaxEnabled = true, + }; + + NewTaxJarConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class NewTaxJarConfigurationTaxProviderTest : TestBase diff --git a/src/Orb.Tests/Models/DimensionalPriceConfigurationTest.cs b/src/Orb.Tests/Models/DimensionalPriceConfigurationTest.cs index 1d1a6510e..f1596296f 100644 --- a/src/Orb.Tests/Models/DimensionalPriceConfigurationTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceConfigurationTest.cs @@ -83,4 +83,18 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DimensionalPriceConfiguration + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }; + + DimensionalPriceConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroupsTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroupsTest.cs index 4abdd173e..923abeb23 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroupsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroupsTest.cs @@ -158,4 +158,29 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DimensionalPriceGroupDimensionalPriceGroups + { + Data = + [ + new() + { + ID = "id", + BillableMetricID = "billable_metric_id", + Dimensions = ["region", "instance_type"], + ExternalDimensionalPriceGroupID = "my_dimensional_price_group_id", + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + DimensionalPriceGroupDimensionalPriceGroups copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupTest.cs index 3b47af609..812e07784 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupTest.cs @@ -133,4 +133,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DimensionalPriceGroup + { + ID = "id", + BillableMetricID = "billable_metric_id", + Dimensions = ["region", "instance_type"], + ExternalDimensionalPriceGroupID = "my_dimensional_price_group_id", + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + }; + + DimensionalPriceGroup copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillCloseResponseTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillCloseResponseTest.cs index d0ee0e815..cd75a127b 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillCloseResponseTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillCloseResponseTest.cs @@ -238,6 +238,29 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BackfillCloseResponse + { + ID = "id", + CloseTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + EventsIngested = 0, + ReplaceExistingEvents = true, + RevertedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = BackfillCloseResponseStatus.Pending, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + DeprecationFilter = "my_numeric_property > 100 AND my_other_property = 'bar'", + }; + + BackfillCloseResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class BackfillCloseResponseStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillCreateResponseTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillCreateResponseTest.cs index 3cac5a9d4..927af0730 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillCreateResponseTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillCreateResponseTest.cs @@ -236,6 +236,29 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BackfillCreateResponse + { + ID = "id", + CloseTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + EventsIngested = 0, + ReplaceExistingEvents = true, + RevertedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = Status.Pending, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + DeprecationFilter = "my_numeric_property > 100 AND my_other_property = 'bar'", + }; + + BackfillCreateResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class StatusTest : TestBase diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillFetchResponseTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillFetchResponseTest.cs index a158c433c..56b097c5a 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillFetchResponseTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillFetchResponseTest.cs @@ -238,6 +238,29 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BackfillFetchResponse + { + ID = "id", + CloseTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + EventsIngested = 0, + ReplaceExistingEvents = true, + RevertedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = BackfillFetchResponseStatus.Pending, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + DeprecationFilter = "my_numeric_property > 100 AND my_other_property = 'bar'", + }; + + BackfillFetchResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class BackfillFetchResponseStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillListPageResponseTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillListPageResponseTest.cs index 57dfd1029..62d394767 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillListPageResponseTest.cs @@ -189,4 +189,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BackfillListPageResponse + { + Data = + [ + new() + { + ID = "id", + CloseTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + EventsIngested = 0, + ReplaceExistingEvents = true, + RevertedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = BackfillListResponseStatus.Pending, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + DeprecationFilter = "my_numeric_property > 100 AND my_other_property = 'bar'", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + BackfillListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillListResponseTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillListResponseTest.cs index 5d6aba9af..5a2f6544e 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillListResponseTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillListResponseTest.cs @@ -238,6 +238,29 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BackfillListResponse + { + ID = "id", + CloseTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + EventsIngested = 0, + ReplaceExistingEvents = true, + RevertedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = BackfillListResponseStatus.Pending, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + DeprecationFilter = "my_numeric_property > 100 AND my_other_property = 'bar'", + }; + + BackfillListResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class BackfillListResponseStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillRevertResponseTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillRevertResponseTest.cs index 3a3814103..cb31fcf80 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillRevertResponseTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillRevertResponseTest.cs @@ -238,6 +238,29 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BackfillRevertResponse + { + ID = "id", + CloseTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + EventsIngested = 0, + ReplaceExistingEvents = true, + RevertedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = BackfillRevertResponseStatus.Pending, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + DeprecationFilter = "my_numeric_property > 100 AND my_other_property = 'bar'", + }; + + BackfillRevertResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class BackfillRevertResponseStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Events/EventDeprecateResponseTest.cs b/src/Orb.Tests/Models/Events/EventDeprecateResponseTest.cs index 798c252f0..d13c075c7 100644 --- a/src/Orb.Tests/Models/Events/EventDeprecateResponseTest.cs +++ b/src/Orb.Tests/Models/Events/EventDeprecateResponseTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventDeprecateResponse { Deprecated = "deprecated" }; + + EventDeprecateResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs b/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs index 10b90d67e..f818a2823 100644 --- a/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs @@ -440,4 +440,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Event + { + 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", + }; + + Event copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Events/EventIngestResponseTest.cs b/src/Orb.Tests/Models/Events/EventIngestResponseTest.cs index 8d4765f04..95d7724c4 100644 --- a/src/Orb.Tests/Models/Events/EventIngestResponseTest.cs +++ b/src/Orb.Tests/Models/Events/EventIngestResponseTest.cs @@ -163,6 +163,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventIngestResponse + { + ValidationFailed = + [ + new() { IdempotencyKey = "idempotency_key", ValidationErrors = ["string"] }, + ], + Debug = new() { Duplicate = ["string"], Ingested = ["string"] }, + }; + + EventIngestResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class ValidationFailedTest : TestBase @@ -243,6 +260,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ValidationFailed + { + IdempotencyKey = "idempotency_key", + ValidationErrors = ["string"], + }; + + ValidationFailed copied = new(model); + + Assert.Equal(model, copied); + } } public class DebugTest : TestBase @@ -309,4 +340,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Debug { Duplicate = ["string"], Ingested = ["string"] }; + + Debug copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Events/EventSearchResponseTest.cs b/src/Orb.Tests/Models/Events/EventSearchResponseTest.cs index 11fe8fd93..bd01ebd9f 100644 --- a/src/Orb.Tests/Models/Events/EventSearchResponseTest.cs +++ b/src/Orb.Tests/Models/Events/EventSearchResponseTest.cs @@ -166,6 +166,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventSearchResponse + { + Data = + [ + new() + { + ID = "id", + CustomerID = "customer_id", + Deprecated = true, + EventName = "event_name", + ExternalCustomerID = "external_customer_id", + Properties = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Timestamp = DateTimeOffset.Parse("2020-12-09T16:09:53Z"), + }, + ], + }; + + EventSearchResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class DataTest : TestBase @@ -302,4 +330,26 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Data + { + ID = "id", + CustomerID = "customer_id", + Deprecated = true, + EventName = "event_name", + ExternalCustomerID = "external_customer_id", + Properties = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Timestamp = DateTimeOffset.Parse("2020-12-09T16:09:53Z"), + }; + + Data copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Events/EventUpdateResponseTest.cs b/src/Orb.Tests/Models/Events/EventUpdateResponseTest.cs index 5f651c8a4..64cc4a192 100644 --- a/src/Orb.Tests/Models/Events/EventUpdateResponseTest.cs +++ b/src/Orb.Tests/Models/Events/EventUpdateResponseTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventUpdateResponse { Amended = "amended" }; + + EventUpdateResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Volume/EventVolumesTest.cs b/src/Orb.Tests/Models/Events/Volume/EventVolumesTest.cs index 24e694eb0..50acbc2d6 100644 --- a/src/Orb.Tests/Models/Events/Volume/EventVolumesTest.cs +++ b/src/Orb.Tests/Models/Events/Volume/EventVolumesTest.cs @@ -124,6 +124,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventVolumes + { + Data = + [ + new() + { + Count = 0, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + }; + + EventVolumes copied = new(model); + + Assert.Equal(model, copied); + } } public class DataTest : TestBase @@ -198,4 +219,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Data + { + Count = 0, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Data copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/FixedFeeQuantityScheduleEntryTest.cs b/src/Orb.Tests/Models/FixedFeeQuantityScheduleEntryTest.cs index 7c137cf11..0695d0d1e 100644 --- a/src/Orb.Tests/Models/FixedFeeQuantityScheduleEntryTest.cs +++ b/src/Orb.Tests/Models/FixedFeeQuantityScheduleEntryTest.cs @@ -91,4 +91,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FixedFeeQuantityScheduleEntry + { + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + FixedFeeQuantityScheduleEntry copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/FixedFeeQuantityTransitionTest.cs b/src/Orb.Tests/Models/FixedFeeQuantityTransitionTest.cs index 7a0764b65..8a0077692 100644 --- a/src/Orb.Tests/Models/FixedFeeQuantityTransitionTest.cs +++ b/src/Orb.Tests/Models/FixedFeeQuantityTransitionTest.cs @@ -83,4 +83,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FixedFeeQuantityTransition + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }; + + FixedFeeQuantityTransition copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs b/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs index e35616bc9..fe397b828 100644 --- a/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs +++ b/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs @@ -1169,6 +1169,192 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceLineItemCreateResponse + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }; + + InvoiceLineItemCreateResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class AdjustmentTest : TestBase diff --git a/src/Orb.Tests/Models/InvoiceTest.cs b/src/Orb.Tests/Models/InvoiceTest.cs index 58b2a64d5..ee2988d89 100644 --- a/src/Orb.Tests/Models/InvoiceTest.cs +++ b/src/Orb.Tests/Models/InvoiceTest.cs @@ -2196,6 +2196,349 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Invoice + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ], + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + 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", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + Invoice copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceAutoCollectionTest : TestBase @@ -2288,6 +2631,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceAutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + InvoiceAutoCollection copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceCreditNoteTest : TestBase @@ -2400,6 +2759,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceCreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + InvoiceCreditNote copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceCustomerBalanceTransactionTest : TestBase @@ -2540,6 +2918,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceCustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceCustomerBalanceTransactionType.Increment, + }; + + InvoiceCustomerBalanceTransaction copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceCustomerBalanceTransactionActionTest : TestBase @@ -3842,6 +4242,185 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceLineItem + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }; + + InvoiceLineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceLineItemAdjustmentTest : TestBase @@ -4374,6 +4953,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoicePaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }; + + InvoicePaymentAttempt copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoicePaymentAttemptPaymentProviderTest : TestBase diff --git a/src/Orb.Tests/Models/InvoiceTinyTest.cs b/src/Orb.Tests/Models/InvoiceTinyTest.cs index 513632ddf..9ca2ecd8a 100644 --- a/src/Orb.Tests/Models/InvoiceTinyTest.cs +++ b/src/Orb.Tests/Models/InvoiceTinyTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceTiny { ID = "gXcsPTVyC4YZa3Sc" }; + + InvoiceTiny copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs index 8cca91c82..c62ba2824 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs @@ -496,6 +496,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LineItem + { + 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 }, + }; + + LineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class ModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs index 9439dde18..f76bd64b9 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs @@ -2202,6 +2202,349 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Invoices::InvoiceFetchUpcomingResponse + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Invoices::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Invoices::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ], + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Invoices::InvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + 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", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Invoices::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Invoices::InvoiceFetchUpcomingResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TargetDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + Invoices::InvoiceFetchUpcomingResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class AutoCollectionTest : TestBase @@ -2294,6 +2637,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Invoices::AutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Invoices::AutoCollection copied = new(model); + + Assert.Equal(model, copied); + } } public class CreditNoteTest : TestBase @@ -2406,6 +2765,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Invoices::CreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + Invoices::CreditNote copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerBalanceTransactionTest : TestBase @@ -2542,6 +2920,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Invoices::CustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Invoices::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Invoices::Type.Increment, + }; + + Invoices::CustomerBalanceTransaction copied = new(model); + + Assert.Equal(model, copied); + } } public class ActionTest : TestBase @@ -3854,6 +4254,185 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Invoices::InvoiceFetchUpcomingResponseLineItem + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }; + + Invoices::InvoiceFetchUpcomingResponseLineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class AdjustmentTest : TestBase @@ -4386,6 +4965,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Invoices::PaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Invoices::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }; + + Invoices::PaymentAttempt copied = new(model); + + Assert.Equal(model, copied); + } } public class PaymentProviderTest : TestBase diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs index fa6499a9c..e2fd330f0 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs @@ -2117,4 +2117,356 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceListPageResponse + { + Data = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ], + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + 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", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + InvoiceListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryPageResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryPageResponseTest.cs index 57c48cf0b..d435f593e 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryPageResponseTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryPageResponseTest.cs @@ -743,4 +743,127 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceListSummaryPageResponse + { + Data = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceListSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = + InvoiceListSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceListSummaryResponseInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + InvoiceListSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceListSummaryResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + InvoiceListSummaryPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryResponseTest.cs index 510dbc4ca..39a627145 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryResponseTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryResponseTest.cs @@ -798,6 +798,120 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceListSummaryResponse + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceListSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceListSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceListSummaryResponseInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + InvoiceListSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceListSummaryResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + InvoiceListSummaryResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceListSummaryResponseAutoCollectionTest : TestBase @@ -890,6 +1004,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceListSummaryResponseAutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + InvoiceListSummaryResponseAutoCollection copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceListSummaryResponseCreditNoteTest : TestBase @@ -1002,6 +1132,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceListSummaryResponseCreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + InvoiceListSummaryResponseCreditNote copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceListSummaryResponseCustomerBalanceTransactionTest : TestBase @@ -1144,6 +1293,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceListSummaryResponseCustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceListSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceListSummaryResponseCustomerBalanceTransactionType.Increment, + }; + + InvoiceListSummaryResponseCustomerBalanceTransaction copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceListSummaryResponseCustomerBalanceTransactionActionTest : TestBase @@ -1452,6 +1623,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceListSummaryResponsePaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoiceListSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }; + + InvoiceListSummaryResponsePaymentAttempt copied = new(model); + + Assert.Equal(model, copied); + } } public class InvoiceListSummaryResponsePaymentAttemptPaymentProviderTest : TestBase diff --git a/src/Orb.Tests/Models/ItemSlimTest.cs b/src/Orb.Tests/Models/ItemSlimTest.cs index 353616596..072d6e0c5 100644 --- a/src/Orb.Tests/Models/ItemSlimTest.cs +++ b/src/Orb.Tests/Models/ItemSlimTest.cs @@ -55,4 +55,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ItemSlim { ID = "id", Name = "name" }; + + ItemSlim copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Items/ItemListPageResponseTest.cs b/src/Orb.Tests/Models/Items/ItemListPageResponseTest.cs index 11a21c729..4ef40575d 100644 --- a/src/Orb.Tests/Models/Items/ItemListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Items/ItemListPageResponseTest.cs @@ -207,4 +207,37 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ItemListPageResponse + { + Data = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalConnections = + [ + new() + { + ExternalConnectionName = + ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + ItemListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Items/ItemTest.cs b/src/Orb.Tests/Models/Items/ItemTest.cs index 009d3f05a..05a9c5e06 100644 --- a/src/Orb.Tests/Models/Items/ItemTest.cs +++ b/src/Orb.Tests/Models/Items/ItemTest.cs @@ -259,6 +259,31 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Item + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalConnections = + [ + new() + { + ExternalConnectionName = ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Item copied = new(model); + + Assert.Equal(model, copied); + } } public class ItemExternalConnectionTest : TestBase @@ -337,6 +362,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ItemExternalConnection + { + ExternalConnectionName = ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }; + + ItemExternalConnection copied = new(model); + + Assert.Equal(model, copied); + } } public class ItemExternalConnectionExternalConnectionNameTest : TestBase diff --git a/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs b/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs index 1def788ec..41619753f 100644 --- a/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs @@ -196,6 +196,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ExternalConnection + { + ExternalConnectionName = ExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }; + + ExternalConnection copied = new(model); + + Assert.Equal(model, copied); + } } public class ExternalConnectionNameTest : TestBase diff --git a/src/Orb.Tests/Models/MatrixConfigTest.cs b/src/Orb.Tests/Models/MatrixConfigTest.cs index d30ba87f6..6a58d3fad 100644 --- a/src/Orb.Tests/Models/MatrixConfigTest.cs +++ b/src/Orb.Tests/Models/MatrixConfigTest.cs @@ -105,4 +105,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixConfig + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + MatrixConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/MatrixSubLineItemTest.cs b/src/Orb.Tests/Models/MatrixSubLineItemTest.cs index d533dd045..94a9cf2bd 100644 --- a/src/Orb.Tests/Models/MatrixSubLineItemTest.cs +++ b/src/Orb.Tests/Models/MatrixSubLineItemTest.cs @@ -185,6 +185,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixSubLineItem + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }; + + MatrixSubLineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixSubLineItemTypeTest : TestBase diff --git a/src/Orb.Tests/Models/MatrixValueTest.cs b/src/Orb.Tests/Models/MatrixValueTest.cs index 1046943da..846503af7 100644 --- a/src/Orb.Tests/Models/MatrixValueTest.cs +++ b/src/Orb.Tests/Models/MatrixValueTest.cs @@ -67,4 +67,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/MatrixWithAllocationConfigTest.cs b/src/Orb.Tests/Models/MatrixWithAllocationConfigTest.cs index 8bfc6c94a..0c378f59b 100644 --- a/src/Orb.Tests/Models/MatrixWithAllocationConfigTest.cs +++ b/src/Orb.Tests/Models/MatrixWithAllocationConfigTest.cs @@ -113,6 +113,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationConfig + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + MatrixWithAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithAllocationConfigMatrixValueTest : TestBase @@ -193,4 +209,18 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + MatrixWithAllocationConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/MaximumIntervalTest.cs b/src/Orb.Tests/Models/MaximumIntervalTest.cs index 56d7d795a..00360a03a 100644 --- a/src/Orb.Tests/Models/MaximumIntervalTest.cs +++ b/src/Orb.Tests/Models/MaximumIntervalTest.cs @@ -174,6 +174,31 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaximumInterval + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = MaximumIntervalFilterField.PriceID, + Operator = MaximumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + MaximumInterval copied = new(model); + + Assert.Equal(model, copied); + } } public class MaximumIntervalFilterTest : TestBase @@ -266,6 +291,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaximumIntervalFilter + { + Field = MaximumIntervalFilterField.PriceID, + Operator = MaximumIntervalFilterOperator.Includes, + Values = ["string"], + }; + + MaximumIntervalFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MaximumIntervalFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/MaximumTest.cs b/src/Orb.Tests/Models/MaximumTest.cs index 18740f5ea..d7d4e51e9 100644 --- a/src/Orb.Tests/Models/MaximumTest.cs +++ b/src/Orb.Tests/Models/MaximumTest.cs @@ -145,6 +145,29 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Maximum + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }; + + Maximum copied = new(model); + + Assert.Equal(model, copied); + } } public class MaximumFilterTest : TestBase @@ -233,6 +256,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaximumFilter + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }; + + MaximumFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MaximumFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/Metrics/BillableMetricTest.cs b/src/Orb.Tests/Models/Metrics/BillableMetricTest.cs index b1670160f..8cd407cf1 100644 --- a/src/Orb.Tests/Models/Metrics/BillableMetricTest.cs +++ b/src/Orb.Tests/Models/Metrics/BillableMetricTest.cs @@ -216,6 +216,40 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BillableMetric + { + ID = "id", + Description = "description", + Item = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalConnections = + [ + new() + { + ExternalConnectionName = + ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + Status = Status.Active, + }; + + BillableMetric copied = new(model); + + Assert.Equal(model, copied); + } } public class StatusTest : TestBase diff --git a/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs b/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs index 317bd3c4e..3cbb9c4e5 100644 --- a/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs @@ -256,4 +256,45 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MetricListPageResponse + { + Data = + [ + new() + { + ID = "id", + Description = "description", + Item = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalConnections = + [ + new() + { + ExternalConnectionName = + ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + Status = Status.Active, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + MetricListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/MinimumIntervalTest.cs b/src/Orb.Tests/Models/MinimumIntervalTest.cs index 4198783a1..d4dfb9cbd 100644 --- a/src/Orb.Tests/Models/MinimumIntervalTest.cs +++ b/src/Orb.Tests/Models/MinimumIntervalTest.cs @@ -174,6 +174,31 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumInterval + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = MinimumIntervalFilterField.PriceID, + Operator = MinimumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + MinimumInterval copied = new(model); + + Assert.Equal(model, copied); + } } public class MinimumIntervalFilterTest : TestBase @@ -266,6 +291,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumIntervalFilter + { + Field = MinimumIntervalFilterField.PriceID, + Operator = MinimumIntervalFilterOperator.Includes, + Values = ["string"], + }; + + MinimumIntervalFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MinimumIntervalFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/MinimumTest.cs b/src/Orb.Tests/Models/MinimumTest.cs index 6e31dca0e..b0b9ae8a1 100644 --- a/src/Orb.Tests/Models/MinimumTest.cs +++ b/src/Orb.Tests/Models/MinimumTest.cs @@ -145,6 +145,29 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Minimum + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }; + + Minimum copied = new(model); + + Assert.Equal(model, copied); + } } public class MinimumFilterTest : TestBase @@ -233,6 +256,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumFilter + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }; + + MinimumFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MinimumFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/MonetaryAmountDiscountAdjustmentTest.cs b/src/Orb.Tests/Models/MonetaryAmountDiscountAdjustmentTest.cs index 57594f5bd..ecb11546a 100644 --- a/src/Orb.Tests/Models/MonetaryAmountDiscountAdjustmentTest.cs +++ b/src/Orb.Tests/Models/MonetaryAmountDiscountAdjustmentTest.cs @@ -196,6 +196,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryAmountDiscountAdjustment + { + ID = "id", + AdjustmentType = AdjustmentType.AmountDiscount, + Amount = "amount", + AmountDiscount = "amount_discount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryAmountDiscountAdjustmentFilterField.PriceID, + Operator = MonetaryAmountDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + MonetaryAmountDiscountAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class AdjustmentTypeTest : TestBase @@ -344,6 +373,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryAmountDiscountAdjustmentFilter + { + Field = MonetaryAmountDiscountAdjustmentFilterField.PriceID, + Operator = MonetaryAmountDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + MonetaryAmountDiscountAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryAmountDiscountAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/MonetaryMaximumAdjustmentTest.cs b/src/Orb.Tests/Models/MonetaryMaximumAdjustmentTest.cs index ba43107f8..b32fd7d04 100644 --- a/src/Orb.Tests/Models/MonetaryMaximumAdjustmentTest.cs +++ b/src/Orb.Tests/Models/MonetaryMaximumAdjustmentTest.cs @@ -198,6 +198,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryMaximumAdjustment + { + ID = "id", + AdjustmentType = MonetaryMaximumAdjustmentAdjustmentType.Maximum, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryMaximumAdjustmentFilterField.PriceID, + Operator = MonetaryMaximumAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + MaximumAmount = "maximum_amount", + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + MonetaryMaximumAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryMaximumAdjustmentAdjustmentTypeTest : TestBase @@ -342,6 +371,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryMaximumAdjustmentFilter + { + Field = MonetaryMaximumAdjustmentFilterField.PriceID, + Operator = MonetaryMaximumAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + MonetaryMaximumAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryMaximumAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/MonetaryMinimumAdjustmentTest.cs b/src/Orb.Tests/Models/MonetaryMinimumAdjustmentTest.cs index b907d62f7..2bf389375 100644 --- a/src/Orb.Tests/Models/MonetaryMinimumAdjustmentTest.cs +++ b/src/Orb.Tests/Models/MonetaryMinimumAdjustmentTest.cs @@ -206,6 +206,36 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryMinimumAdjustment + { + ID = "id", + AdjustmentType = MonetaryMinimumAdjustmentAdjustmentType.Minimum, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryMinimumAdjustmentFilterField.PriceID, + Operator = MonetaryMinimumAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + MonetaryMinimumAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryMinimumAdjustmentAdjustmentTypeTest : TestBase @@ -350,6 +380,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryMinimumAdjustmentFilter + { + Field = MonetaryMinimumAdjustmentFilterField.PriceID, + Operator = MonetaryMinimumAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + MonetaryMinimumAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryMinimumAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/MonetaryPercentageDiscountAdjustmentTest.cs b/src/Orb.Tests/Models/MonetaryPercentageDiscountAdjustmentTest.cs index 2e4ff8edd..f0d959fb9 100644 --- a/src/Orb.Tests/Models/MonetaryPercentageDiscountAdjustmentTest.cs +++ b/src/Orb.Tests/Models/MonetaryPercentageDiscountAdjustmentTest.cs @@ -198,6 +198,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryPercentageDiscountAdjustment + { + ID = "id", + AdjustmentType = MonetaryPercentageDiscountAdjustmentAdjustmentType.PercentageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryPercentageDiscountAdjustmentFilterField.PriceID, + Operator = MonetaryPercentageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PercentageDiscount = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + MonetaryPercentageDiscountAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryPercentageDiscountAdjustmentAdjustmentTypeTest : TestBase @@ -344,6 +373,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryPercentageDiscountAdjustmentFilter + { + Field = MonetaryPercentageDiscountAdjustmentFilterField.PriceID, + Operator = MonetaryPercentageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + MonetaryPercentageDiscountAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryPercentageDiscountAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/MonetaryUsageDiscountAdjustmentTest.cs b/src/Orb.Tests/Models/MonetaryUsageDiscountAdjustmentTest.cs index 9ff303975..ddba0f2d8 100644 --- a/src/Orb.Tests/Models/MonetaryUsageDiscountAdjustmentTest.cs +++ b/src/Orb.Tests/Models/MonetaryUsageDiscountAdjustmentTest.cs @@ -198,6 +198,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryUsageDiscountAdjustment + { + ID = "id", + AdjustmentType = MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }; + + MonetaryUsageDiscountAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryUsageDiscountAdjustmentAdjustmentTypeTest : TestBase @@ -342,6 +371,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MonetaryUsageDiscountAdjustmentFilter + { + Field = MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + MonetaryUsageDiscountAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MonetaryUsageDiscountAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/NewAllocationPriceTest.cs b/src/Orb.Tests/Models/NewAllocationPriceTest.cs index 2843bdaf2..ca3fd21fa 100644 --- a/src/Orb.Tests/Models/NewAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewAllocationPriceTest.cs @@ -410,6 +410,38 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewAllocationPrice + { + 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", + }; + + NewAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -566,6 +598,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewAllocationPriceFilter + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }; + + NewAllocationPriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class NewAllocationPriceFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/NewAmountDiscountTest.cs b/src/Orb.Tests/Models/NewAmountDiscountTest.cs index c2da99786..6036811ae 100644 --- a/src/Orb.Tests/Models/NewAmountDiscountTest.cs +++ b/src/Orb.Tests/Models/NewAmountDiscountTest.cs @@ -412,6 +412,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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, + }; + + NewAmountDiscount copied = new(model); + + Assert.Equal(model, copied); + } } public class NewAmountDiscountAdjustmentTypeTest : TestBase @@ -614,6 +643,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewAmountDiscountFilter + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }; + + NewAmountDiscountFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class NewAmountDiscountFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/NewBillingCycleConfigurationTest.cs b/src/Orb.Tests/Models/NewBillingCycleConfigurationTest.cs index 29674994b..192125efc 100644 --- a/src/Orb.Tests/Models/NewBillingCycleConfigurationTest.cs +++ b/src/Orb.Tests/Models/NewBillingCycleConfigurationTest.cs @@ -77,6 +77,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewBillingCycleConfiguration + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + + NewBillingCycleConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class NewBillingCycleConfigurationDurationUnitTest : TestBase diff --git a/src/Orb.Tests/Models/NewDimensionalPriceConfigurationTest.cs b/src/Orb.Tests/Models/NewDimensionalPriceConfigurationTest.cs index 61e50371b..06cff0b1b 100644 --- a/src/Orb.Tests/Models/NewDimensionalPriceConfigurationTest.cs +++ b/src/Orb.Tests/Models/NewDimensionalPriceConfigurationTest.cs @@ -147,4 +147,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewDimensionalPriceConfiguration + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + + NewDimensionalPriceConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/NewFloatingBulkPriceTest.cs b/src/Orb.Tests/Models/NewFloatingBulkPriceTest.cs index 65e99b9b8..42a0b1161 100644 --- a/src/Orb.Tests/Models/NewFloatingBulkPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingBulkPriceTest.cs @@ -451,6 +451,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingBulkPrice + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = NewFloatingBulkPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingBulkPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingBulkWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingBulkWithProrationPriceTest.cs index 610b39d5a..dc319ab6e 100644 --- a/src/Orb.Tests/Models/NewFloatingBulkWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingBulkWithProrationPriceTest.cs @@ -501,6 +501,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingBulkWithProrationPrice + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = NewFloatingBulkWithProrationPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingBulkWithProrationPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingBulkWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationConfigTest : TestBase @@ -597,6 +648,23 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TierTest : TestBase @@ -691,6 +759,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingBulkWithProrationPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingCumulativeGroupedBulkPriceTest.cs b/src/Orb.Tests/Models/NewFloatingCumulativeGroupedBulkPriceTest.cs index c462015fa..44be2e9db 100644 --- a/src/Orb.Tests/Models/NewFloatingCumulativeGroupedBulkPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingCumulativeGroupedBulkPriceTest.cs @@ -571,6 +571,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingCumulativeGroupedBulkPrice + { + Cadence = NewFloatingCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingCumulativeGroupedBulkPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingCumulativeGroupedBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingCumulativeGroupedBulkPriceCadenceTest : TestBase @@ -761,6 +819,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + CumulativeGroupedBulkConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class DimensionValueTest : TestBase @@ -841,6 +921,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + DimensionValue copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingCumulativeGroupedBulkPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingGroupedAllocationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedAllocationPriceTest.cs index 3226c6fd5..9de25e6b5 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedAllocationPriceTest.cs @@ -501,6 +501,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingGroupedAllocationPrice + { + Cadence = NewFloatingGroupedAllocationPriceCadence.Annual, + Currency = "currency", + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = NewFloatingGroupedAllocationPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingGroupedAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedAllocationPriceCadenceTest : TestBase @@ -643,6 +694,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + GroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedAllocationPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingGroupedTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedTieredPackagePriceTest.cs index 016b9187f..d1f29a391 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedTieredPackagePriceTest.cs @@ -541,6 +541,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingGroupedTieredPackagePrice + { + Cadence = NewFloatingGroupedTieredPackagePriceCadence.Annual, + Currency = "currency", + 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 = NewFloatingGroupedTieredPackagePriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingGroupedTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedTieredPackagePriceCadenceTest : TestBase @@ -715,6 +770,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + GroupedTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageConfigTierTest : TestBase @@ -787,6 +861,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + GroupedTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedTieredPackagePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingGroupedTieredPriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedTieredPriceTest.cs index d448f3405..cd14ea0f0 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedTieredPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedTieredPriceTest.cs @@ -531,6 +531,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingGroupedTieredPrice + { + Cadence = NewFloatingGroupedTieredPriceCadence.Annual, + Currency = "currency", + 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 = NewFloatingGroupedTieredPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingGroupedTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedTieredPriceCadenceTest : TestBase @@ -697,6 +751,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + GroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredConfigTierTest : TestBase @@ -769,6 +841,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + GroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedTieredPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingGroupedWithMeteredMinimumPriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedWithMeteredMinimumPriceTest.cs index 76b2d587d..520ab91b1 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedWithMeteredMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedWithMeteredMinimumPriceTest.cs @@ -605,6 +605,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingGroupedWithMeteredMinimumPrice + { + Cadence = NewFloatingGroupedWithMeteredMinimumPriceCadence.Annual, + Currency = "currency", + 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 = + NewFloatingGroupedWithMeteredMinimumPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingGroupedWithMeteredMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedWithMeteredMinimumPriceCadenceTest : TestBase @@ -825,6 +886,30 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + GroupedWithMeteredMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalingFactorTest : TestBase @@ -897,6 +982,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + ScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitAmountTest : TestBase @@ -969,6 +1068,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + UnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedWithMeteredMinimumPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingGroupedWithProratedMinimumPriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedWithProratedMinimumPriceTest.cs index 5bb4e70ac..a310707ed 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedWithProratedMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedWithProratedMinimumPriceTest.cs @@ -515,6 +515,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingGroupedWithProratedMinimumPrice + { + Cadence = NewFloatingGroupedWithProratedMinimumPriceCadence.Annual, + Currency = "currency", + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + NewFloatingGroupedWithProratedMinimumPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingGroupedWithProratedMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedWithProratedMinimumPriceCadenceTest : TestBase @@ -659,6 +711,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + GroupedWithProratedMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedWithProratedMinimumPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingMatrixPriceTest.cs b/src/Orb.Tests/Models/NewFloatingMatrixPriceTest.cs index 29e39008b..d65f39411 100644 --- a/src/Orb.Tests/Models/NewFloatingMatrixPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMatrixPriceTest.cs @@ -501,6 +501,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingMatrixPrice + { + Cadence = NewFloatingMatrixPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = NewFloatingMatrixPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingMatrixPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMatrixPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingMatrixWithAllocationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingMatrixWithAllocationPriceTest.cs index 5e9d9b01f..80d259b1a 100644 --- a/src/Orb.Tests/Models/NewFloatingMatrixWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMatrixWithAllocationPriceTest.cs @@ -511,6 +511,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingMatrixWithAllocationPrice + { + Cadence = NewFloatingMatrixWithAllocationPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = NewFloatingMatrixWithAllocationPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingMatrixWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMatrixWithAllocationPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingMatrixWithDisplayNamePriceTest.cs b/src/Orb.Tests/Models/NewFloatingMatrixWithDisplayNamePriceTest.cs index 671850aa0..45263ef37 100644 --- a/src/Orb.Tests/Models/NewFloatingMatrixWithDisplayNamePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMatrixWithDisplayNamePriceTest.cs @@ -571,6 +571,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingMatrixWithDisplayNamePrice + { + Cadence = NewFloatingMatrixWithDisplayNamePriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = NewFloatingMatrixWithDisplayNamePriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingMatrixWithDisplayNamePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMatrixWithDisplayNamePriceCadenceTest : TestBase @@ -761,6 +819,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + MatrixWithDisplayNameConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameConfigUnitAmountTest : TestBase @@ -841,6 +921,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + MatrixWithDisplayNameConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMatrixWithDisplayNamePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingMaxGroupTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewFloatingMaxGroupTieredPackagePriceTest.cs index 6cf522d1e..60a2e9702 100644 --- a/src/Orb.Tests/Models/NewFloatingMaxGroupTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMaxGroupTieredPackagePriceTest.cs @@ -541,6 +541,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingMaxGroupTieredPackagePrice + { + Cadence = NewFloatingMaxGroupTieredPackagePriceCadence.Annual, + Currency = "currency", + 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 = NewFloatingMaxGroupTieredPackagePriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingMaxGroupTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMaxGroupTieredPackagePriceCadenceTest : TestBase @@ -715,6 +770,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + MaxGroupTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackageConfigTierTest : TestBase @@ -787,6 +861,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + MaxGroupTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMaxGroupTieredPackagePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingMinimumCompositePriceTest.cs b/src/Orb.Tests/Models/NewFloatingMinimumCompositePriceTest.cs index 15270f905..0a1310731 100644 --- a/src/Orb.Tests/Models/NewFloatingMinimumCompositePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMinimumCompositePriceTest.cs @@ -459,6 +459,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingMinimumCompositePrice + { + Cadence = NewFloatingMinimumCompositePriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = NewFloatingMinimumCompositePriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingMinimumCompositePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMinimumCompositePriceCadenceTest : TestBase @@ -639,6 +685,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + MinimumCompositeConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMinimumCompositePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingPackagePriceTest.cs b/src/Orb.Tests/Models/NewFloatingPackagePriceTest.cs index 3eb4b5043..d96f07c8b 100644 --- a/src/Orb.Tests/Models/NewFloatingPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingPackagePriceTest.cs @@ -459,6 +459,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingPackagePrice + { + Cadence = NewFloatingPackagePriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingPackagePriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingPackagePriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingPackageWithAllocationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingPackageWithAllocationPriceTest.cs index 846484254..71371203a 100644 --- a/src/Orb.Tests/Models/NewFloatingPackageWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingPackageWithAllocationPriceTest.cs @@ -501,6 +501,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingPackageWithAllocationPrice + { + Cadence = NewFloatingPackageWithAllocationPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingPackageWithAllocationPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingPackageWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingPackageWithAllocationPriceCadenceTest : TestBase @@ -697,6 +748,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + PackageWithAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingPackageWithAllocationPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithTieredPricingPriceTest.cs b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithTieredPricingPriceTest.cs index 91f3fefe6..36d6b221c 100644 --- a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithTieredPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithTieredPricingPriceTest.cs @@ -653,6 +653,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingScalableMatrixWithTieredPricingPrice + { + Cadence = NewFloatingScalableMatrixWithTieredPricingPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = + NewFloatingScalableMatrixWithTieredPricingPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingScalableMatrixWithTieredPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingScalableMatrixWithTieredPricingPriceCadenceTest : TestBase @@ -1057,6 +1122,34 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + ScalableMatrixWithTieredPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixScalingFactorTest : TestBase @@ -1191,6 +1284,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + MatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingConfigTierTest : TestBase @@ -1263,6 +1371,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ScalableMatrixWithTieredPricingConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingScalableMatrixWithTieredPricingPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs index dde388c67..12c1fdd6f 100644 --- a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs @@ -617,6 +617,68 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingScalableMatrixWithUnitPricingPrice + { + Cadence = NewFloatingScalableMatrixWithUnitPricingPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = + NewFloatingScalableMatrixWithUnitPricingPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingScalableMatrixWithUnitPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingScalableMatrixWithUnitPricingPriceCadenceTest : TestBase @@ -987,6 +1049,31 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest : TestBase @@ -1123,6 +1210,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ScalableMatrixWithUnitPricingConfigMatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingScalableMatrixWithUnitPricingPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingThresholdTotalAmountPriceTest.cs b/src/Orb.Tests/Models/NewFloatingThresholdTotalAmountPriceTest.cs index 4a88e89fd..6c58b1c0e 100644 --- a/src/Orb.Tests/Models/NewFloatingThresholdTotalAmountPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingThresholdTotalAmountPriceTest.cs @@ -531,6 +531,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingThresholdTotalAmountPrice + { + Cadence = NewFloatingThresholdTotalAmountPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingThresholdTotalAmountPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingThresholdTotalAmountPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingThresholdTotalAmountPriceCadenceTest : TestBase @@ -815,6 +869,24 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + ThresholdTotalAmountConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ConsumptionTableTest : TestBase @@ -871,6 +943,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + ConsumptionTable copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingThresholdTotalAmountPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredPackagePriceTest.cs index d875c1b1f..fe026846b 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredPackagePriceTest.cs @@ -531,6 +531,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingTieredPackagePrice + { + Cadence = NewFloatingTieredPackagePriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingTieredPackagePriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredPackagePriceCadenceTest : TestBase @@ -749,6 +803,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + TieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageConfigTierTest : TestBase @@ -821,6 +893,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredPackagePriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingTieredPackageWithMinimumPriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredPackageWithMinimumPriceTest.cs index 51cda01bc..43546d984 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredPackageWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredPackageWithMinimumPriceTest.cs @@ -634,6 +634,70 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingTieredPackageWithMinimumPrice + { + Cadence = NewFloatingTieredPackageWithMinimumPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingTieredPackageWithMinimumPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingTieredPackageWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredPackageWithMinimumPriceCadenceTest : TestBase @@ -916,6 +980,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + TieredPackageWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageWithMinimumConfigTierTest : TestBase @@ -996,6 +1088,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredPackageWithMinimumPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingTieredPriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredPriceTest.cs index d06e20a32..dd9e298fa 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredPriceTest.cs @@ -571,6 +571,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingTieredPrice + { + Cadence = NewFloatingTieredPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingTieredPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingTieredWithMinimumPriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredWithMinimumPriceTest.cs index 97c798e2c..c6c576e1e 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredWithMinimumPriceTest.cs @@ -641,6 +641,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingTieredWithMinimumPrice + { + Cadence = NewFloatingTieredWithMinimumPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingTieredWithMinimumPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingTieredWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredWithMinimumPriceCadenceTest : TestBase @@ -1041,6 +1106,35 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + TieredWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithMinimumConfigTierTest : TestBase @@ -1121,6 +1215,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredWithMinimumPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingTieredWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredWithProrationPriceTest.cs index cf9a4f03d..83087aeee 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredWithProrationPriceTest.cs @@ -471,6 +471,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingTieredWithProrationPrice + { + Cadence = NewFloatingTieredWithProrationPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingTieredWithProrationPriceModelType.TieredWithProration, + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingTieredWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredWithProrationPriceCadenceTest : TestBase @@ -663,6 +711,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationConfigTierTest : TestBase @@ -735,6 +796,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredWithProrationPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingUnitPriceTest.cs b/src/Orb.Tests/Models/NewFloatingUnitPriceTest.cs index a37370b3c..cde41dba0 100644 --- a/src/Orb.Tests/Models/NewFloatingUnitPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingUnitPriceTest.cs @@ -451,6 +451,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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" } }, + }; + + NewFloatingUnitPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingUnitPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingUnitWithPercentPriceTest.cs b/src/Orb.Tests/Models/NewFloatingUnitWithPercentPriceTest.cs index c9a2a3add..af7592992 100644 --- a/src/Orb.Tests/Models/NewFloatingUnitWithPercentPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingUnitWithPercentPriceTest.cs @@ -459,6 +459,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingUnitWithPercentPrice + { + Cadence = NewFloatingUnitWithPercentPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingUnitWithPercentPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingUnitWithPercentPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingUnitWithPercentPriceCadenceTest : TestBase @@ -629,6 +675,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + UnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingUnitWithPercentPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewFloatingUnitWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingUnitWithProrationPriceTest.cs index c7f98eccc..9135900d6 100644 --- a/src/Orb.Tests/Models/NewFloatingUnitWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingUnitWithProrationPriceTest.cs @@ -451,6 +451,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewFloatingUnitWithProrationPrice + { + Cadence = NewFloatingUnitWithProrationPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingUnitWithProrationPriceModelType.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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + NewFloatingUnitWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingUnitWithProrationPriceCadenceTest : TestBase @@ -617,6 +663,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + UnitWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingUnitWithProrationPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewMaximumTest.cs b/src/Orb.Tests/Models/NewMaximumTest.cs index a43e80554..79f31ea94 100644 --- a/src/Orb.Tests/Models/NewMaximumTest.cs +++ b/src/Orb.Tests/Models/NewMaximumTest.cs @@ -412,6 +412,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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, + }; + + NewMaximum copied = new(model); + + Assert.Equal(model, copied); + } } public class NewMaximumAdjustmentTypeTest : TestBase @@ -614,6 +643,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewMaximumFilter + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }; + + NewMaximumFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class NewMaximumFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/NewMinimumTest.cs b/src/Orb.Tests/Models/NewMinimumTest.cs index 43a667945..424e776f5 100644 --- a/src/Orb.Tests/Models/NewMinimumTest.cs +++ b/src/Orb.Tests/Models/NewMinimumTest.cs @@ -428,6 +428,36 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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, + }; + + NewMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class NewMinimumAdjustmentTypeTest : TestBase @@ -630,6 +660,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewMinimumFilter + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }; + + NewMinimumFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class NewMinimumFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/NewPercentageDiscountTest.cs b/src/Orb.Tests/Models/NewPercentageDiscountTest.cs index c951c8837..039a8c9af 100644 --- a/src/Orb.Tests/Models/NewPercentageDiscountTest.cs +++ b/src/Orb.Tests/Models/NewPercentageDiscountTest.cs @@ -416,6 +416,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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, + }; + + NewPercentageDiscount copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPercentageDiscountAdjustmentTypeTest : TestBase @@ -614,6 +643,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPercentageDiscountFilter + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }; + + NewPercentageDiscountFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPercentageDiscountFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanBulkPriceTest.cs b/src/Orb.Tests/Models/NewPlanBulkPriceTest.cs index a210bf772..8601928d8 100644 --- a/src/Orb.Tests/Models/NewPlanBulkPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanBulkPriceTest.cs @@ -469,6 +469,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanBulkPrice + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = NewPlanBulkPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanBulkPriceModelType.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", + }; + + NewPlanBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanBulkPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanBulkWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewPlanBulkWithProrationPriceTest.cs index 09114dbc8..61b28c016 100644 --- a/src/Orb.Tests/Models/NewPlanBulkWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanBulkWithProrationPriceTest.cs @@ -517,6 +517,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanBulkWithProrationPrice + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = NewPlanBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanBulkWithProrationPriceModelType.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", + }; + + NewPlanBulkWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanBulkWithProrationPriceBulkWithProrationConfigTest : TestBase @@ -615,6 +667,23 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanBulkWithProrationPriceBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + NewPlanBulkWithProrationPriceBulkWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanBulkWithProrationPriceBulkWithProrationConfigTierTest : TestBase @@ -739,6 +808,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanBulkWithProrationPriceBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + NewPlanBulkWithProrationPriceBulkWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanBulkWithProrationPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanCumulativeGroupedBulkPriceTest.cs b/src/Orb.Tests/Models/NewPlanCumulativeGroupedBulkPriceTest.cs index 8cac7de17..ae78b341e 100644 --- a/src/Orb.Tests/Models/NewPlanCumulativeGroupedBulkPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanCumulativeGroupedBulkPriceTest.cs @@ -589,6 +589,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanCumulativeGroupedBulkPrice + { + Cadence = NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = NewPlanCumulativeGroupedBulkPriceModelType.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", + }; + + NewPlanCumulativeGroupedBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanCumulativeGroupedBulkPriceCadenceTest : TestBase @@ -781,6 +840,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValueTest @@ -864,6 +945,23 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValue copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class NewPlanCumulativeGroupedBulkPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanGroupedAllocationPriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedAllocationPriceTest.cs index 29b4126c7..375f065a7 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedAllocationPriceTest.cs @@ -517,6 +517,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedAllocationPrice + { + Cadence = NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = NewPlanGroupedAllocationPriceModelType.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", + }; + + NewPlanGroupedAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedAllocationPriceCadenceTest : TestBase @@ -661,6 +713,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedAllocationPriceGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + NewPlanGroupedAllocationPriceGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedAllocationPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanGroupedTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedTieredPackagePriceTest.cs index 23c9673ed..d2bf7eb56 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedTieredPackagePriceTest.cs @@ -559,6 +559,62 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedTieredPackagePrice + { + Cadence = NewPlanGroupedTieredPackagePriceCadence.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 = NewPlanGroupedTieredPackagePriceModelType.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", + }; + + NewPlanGroupedTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedTieredPackagePriceCadenceTest : TestBase @@ -735,6 +791,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTierTest : TestBase @@ -809,6 +884,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedTieredPackagePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanGroupedTieredPriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedTieredPriceTest.cs index 9a7e6e1ef..19961073e 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedTieredPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedTieredPriceTest.cs @@ -547,6 +547,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedTieredPrice + { + Cadence = NewPlanGroupedTieredPriceCadence.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 = NewPlanGroupedTieredPriceModelType.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", + }; + + NewPlanGroupedTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedTieredPriceCadenceTest : TestBase @@ -715,6 +770,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedTieredPriceGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + NewPlanGroupedTieredPriceGroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedTieredPriceGroupedTieredConfigTierTest : TestBase @@ -789,6 +862,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedTieredPriceGroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + NewPlanGroupedTieredPriceGroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedTieredPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanGroupedWithMeteredMinimumPriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedWithMeteredMinimumPriceTest.cs index cc0f7f978..dd8af0c5b 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedWithMeteredMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedWithMeteredMinimumPriceTest.cs @@ -615,6 +615,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedWithMeteredMinimumPrice + { + Cadence = NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + ModelType = NewPlanGroupedWithMeteredMinimumPriceModelType.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", + }; + + NewPlanGroupedWithMeteredMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedWithMeteredMinimumPriceCadenceTest : TestBase @@ -823,6 +884,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfig + { + 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" }], + }; + + NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactorTest @@ -902,6 +984,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmountTest @@ -981,6 +1079,23 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmount copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedWithMeteredMinimumPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanGroupedWithProratedMinimumPriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedWithProratedMinimumPriceTest.cs index b366518dc..38ef831da 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedWithProratedMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedWithProratedMinimumPriceTest.cs @@ -525,6 +525,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedWithProratedMinimumPrice + { + Cadence = NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = NewPlanGroupedWithProratedMinimumPriceModelType.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", + }; + + NewPlanGroupedWithProratedMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedWithProratedMinimumPriceCadenceTest : TestBase @@ -669,6 +721,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanGroupedWithProratedMinimumPriceGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + NewPlanGroupedWithProratedMinimumPriceGroupedWithProratedMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedWithProratedMinimumPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanMatrixPriceTest.cs b/src/Orb.Tests/Models/NewPlanMatrixPriceTest.cs index be243f458..af5014ab7 100644 --- a/src/Orb.Tests/Models/NewPlanMatrixPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMatrixPriceTest.cs @@ -517,6 +517,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMatrixPrice + { + Cadence = NewPlanMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = NewPlanMatrixPriceModelType.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", + }; + + NewPlanMatrixPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMatrixPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanMatrixWithAllocationPriceTest.cs b/src/Orb.Tests/Models/NewPlanMatrixWithAllocationPriceTest.cs index 5da1975e2..9108837e1 100644 --- a/src/Orb.Tests/Models/NewPlanMatrixWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMatrixWithAllocationPriceTest.cs @@ -527,6 +527,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMatrixWithAllocationPrice + { + Cadence = NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = NewPlanMatrixWithAllocationPriceModelType.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", + }; + + NewPlanMatrixWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMatrixWithAllocationPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanMatrixWithDisplayNamePriceTest.cs b/src/Orb.Tests/Models/NewPlanMatrixWithDisplayNamePriceTest.cs index 82767e428..3c47204c6 100644 --- a/src/Orb.Tests/Models/NewPlanMatrixWithDisplayNamePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMatrixWithDisplayNamePriceTest.cs @@ -589,6 +589,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMatrixWithDisplayNamePrice + { + Cadence = NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = NewPlanMatrixWithDisplayNamePriceModelType.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", + }; + + NewPlanMatrixWithDisplayNamePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMatrixWithDisplayNamePriceCadenceTest : TestBase @@ -781,6 +840,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmountTest : TestBase @@ -863,6 +944,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMatrixWithDisplayNamePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanMaxGroupTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewPlanMaxGroupTieredPackagePriceTest.cs index 84ede44a6..074719e74 100644 --- a/src/Orb.Tests/Models/NewPlanMaxGroupTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMaxGroupTieredPackagePriceTest.cs @@ -559,6 +559,62 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMaxGroupTieredPackagePrice + { + Cadence = NewPlanMaxGroupTieredPackagePriceCadence.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 = NewPlanMaxGroupTieredPackagePriceModelType.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", + }; + + NewPlanMaxGroupTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMaxGroupTieredPackagePriceCadenceTest : TestBase @@ -735,6 +791,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTierTest : TestBase @@ -809,6 +884,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMaxGroupTieredPackagePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanMinimumCompositePriceTest.cs b/src/Orb.Tests/Models/NewPlanMinimumCompositePriceTest.cs index d24fbaa97..497d9abf8 100644 --- a/src/Orb.Tests/Models/NewPlanMinimumCompositePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMinimumCompositePriceTest.cs @@ -475,6 +475,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMinimumCompositePrice + { + Cadence = NewPlanMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = NewPlanMinimumCompositePriceModelType.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", + }; + + NewPlanMinimumCompositePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMinimumCompositePriceCadenceTest : TestBase @@ -663,6 +710,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanMinimumCompositePriceMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + NewPlanMinimumCompositePriceMinimumCompositeConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMinimumCompositePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanPackagePriceTest.cs b/src/Orb.Tests/Models/NewPlanPackagePriceTest.cs index 2e3119a10..e7fce6e94 100644 --- a/src/Orb.Tests/Models/NewPlanPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanPackagePriceTest.cs @@ -475,6 +475,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanPackagePrice + { + Cadence = NewPlanPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanPackagePriceModelType.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", + }; + + NewPlanPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanPackagePriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanPackageWithAllocationPriceTest.cs b/src/Orb.Tests/Models/NewPlanPackageWithAllocationPriceTest.cs index 5b2c76436..ac93d3f79 100644 --- a/src/Orb.Tests/Models/NewPlanPackageWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanPackageWithAllocationPriceTest.cs @@ -519,6 +519,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanPackageWithAllocationPrice + { + Cadence = NewPlanPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanPackageWithAllocationPriceModelType.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", + }; + + NewPlanPackageWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanPackageWithAllocationPriceCadenceTest : TestBase @@ -715,6 +767,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanPackageWithAllocationPricePackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + NewPlanPackageWithAllocationPricePackageWithAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanPackageWithAllocationPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanScalableMatrixWithTieredPricingPriceTest.cs b/src/Orb.Tests/Models/NewPlanScalableMatrixWithTieredPricingPriceTest.cs index 7f21e23b7..d7b8be3f5 100644 --- a/src/Orb.Tests/Models/NewPlanScalableMatrixWithTieredPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanScalableMatrixWithTieredPricingPriceTest.cs @@ -663,6 +663,72 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanScalableMatrixWithTieredPricingPrice + { + Cadence = NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + NewPlanScalableMatrixWithTieredPricingPriceModelType.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", + }; + + NewPlanScalableMatrixWithTieredPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithTieredPricingPriceCadenceTest : TestBase @@ -1078,6 +1144,36 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfig + { + 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", + }; + + NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest @@ -1223,6 +1319,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTierTest @@ -1302,6 +1415,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithTieredPricingPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs index 4310cfdcb..fc91d28d4 100644 --- a/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs @@ -633,6 +633,69 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanScalableMatrixWithUnitPricingPrice + { + Cadence = NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + NewPlanScalableMatrixWithUnitPricingPriceModelType.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", + }; + + NewPlanScalableMatrixWithUnitPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithUnitPricingPriceCadenceTest : TestBase @@ -1002,6 +1065,33 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }; + + NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest @@ -1147,6 +1237,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithUnitPricingPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanThresholdTotalAmountPriceTest.cs b/src/Orb.Tests/Models/NewPlanThresholdTotalAmountPriceTest.cs index 8b6104318..9f7918c9f 100644 --- a/src/Orb.Tests/Models/NewPlanThresholdTotalAmountPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanThresholdTotalAmountPriceTest.cs @@ -549,6 +549,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanThresholdTotalAmountPrice + { + Cadence = NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanThresholdTotalAmountPriceModelType.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", + }; + + NewPlanThresholdTotalAmountPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanThresholdTotalAmountPriceCadenceTest : TestBase @@ -835,6 +890,24 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTableTest @@ -910,6 +983,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTable copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class NewPlanThresholdTotalAmountPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewPlanTieredPackagePriceTest.cs index c9de41547..dab3533ad 100644 --- a/src/Orb.Tests/Models/NewPlanTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanTieredPackagePriceTest.cs @@ -547,6 +547,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredPackagePrice + { + Cadence = NewPlanTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanTieredPackagePriceModelType.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", + }; + + NewPlanTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPackagePriceCadenceTest : TestBase @@ -769,6 +824,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredPackagePriceTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + NewPlanTieredPackagePriceTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPackagePriceTieredPackageConfigTierTest : TestBase @@ -843,6 +916,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredPackagePriceTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + NewPlanTieredPackagePriceTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPackagePriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanTieredPackageWithMinimumPriceTest.cs b/src/Orb.Tests/Models/NewPlanTieredPackageWithMinimumPriceTest.cs index 7184acfc2..19e8a8887 100644 --- a/src/Orb.Tests/Models/NewPlanTieredPackageWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanTieredPackageWithMinimumPriceTest.cs @@ -652,6 +652,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredPackageWithMinimumPrice + { + Cadence = NewPlanTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanTieredPackageWithMinimumPriceModelType.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", + }; + + NewPlanTieredPackageWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPackageWithMinimumPriceCadenceTest : TestBase @@ -932,6 +997,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTierTest : TestBase @@ -1014,6 +1107,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPackageWithMinimumPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanTieredPriceTest.cs b/src/Orb.Tests/Models/NewPlanTieredPriceTest.cs index 21e5864c0..bfd258249 100644 --- a/src/Orb.Tests/Models/NewPlanTieredPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanTieredPriceTest.cs @@ -587,6 +587,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredPrice + { + Cadence = NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanTieredPriceModelType.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", + }; + + NewPlanTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanTieredWithMinimumPriceTest.cs b/src/Orb.Tests/Models/NewPlanTieredWithMinimumPriceTest.cs index 8d352c7f4..337458ae7 100644 --- a/src/Orb.Tests/Models/NewPlanTieredWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanTieredWithMinimumPriceTest.cs @@ -657,6 +657,72 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredWithMinimumPrice + { + Cadence = NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanTieredWithMinimumPriceModelType.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", + }; + + NewPlanTieredWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredWithMinimumPriceCadenceTest : TestBase @@ -1059,6 +1125,35 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredWithMinimumPriceTieredWithMinimumConfig + { + 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, + }; + + NewPlanTieredWithMinimumPriceTieredWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredWithMinimumPriceTieredWithMinimumConfigTierTest : TestBase @@ -1141,6 +1236,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanTieredWithMinimumPriceTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + NewPlanTieredWithMinimumPriceTieredWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredWithMinimumPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanUnitPriceTest.cs b/src/Orb.Tests/Models/NewPlanUnitPriceTest.cs index efda7a84f..6b0ccfd11 100644 --- a/src/Orb.Tests/Models/NewPlanUnitPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanUnitPriceTest.cs @@ -465,6 +465,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanUnitPrice + { + Cadence = NewPlanUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanUnitPriceModelType.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", + }; + + NewPlanUnitPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanUnitPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanUnitWithPercentPriceTest.cs b/src/Orb.Tests/Models/NewPlanUnitWithPercentPriceTest.cs index 51974e556..506526242 100644 --- a/src/Orb.Tests/Models/NewPlanUnitWithPercentPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanUnitWithPercentPriceTest.cs @@ -475,6 +475,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanUnitWithPercentPrice + { + Cadence = NewPlanUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanUnitWithPercentPriceModelType.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", + }; + + NewPlanUnitWithPercentPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanUnitWithPercentPriceCadenceTest : TestBase @@ -665,6 +712,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanUnitWithPercentPriceUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + NewPlanUnitWithPercentPriceUnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanUnitWithPercentPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewPlanUnitWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewPlanUnitWithProrationPriceTest.cs index 57d3e174a..afbd17608 100644 --- a/src/Orb.Tests/Models/NewPlanUnitWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanUnitWithProrationPriceTest.cs @@ -471,6 +471,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanUnitWithProrationPrice + { + Cadence = NewPlanUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = NewPlanUnitWithProrationPriceModelType.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", + }; + + NewPlanUnitWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanUnitWithProrationPriceCadenceTest : TestBase @@ -651,6 +698,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewPlanUnitWithProrationPriceUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + NewPlanUnitWithProrationPriceUnitWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanUnitWithProrationPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/NewUsageDiscountTest.cs b/src/Orb.Tests/Models/NewUsageDiscountTest.cs index ac6742f2d..444b575c0 100644 --- a/src/Orb.Tests/Models/NewUsageDiscountTest.cs +++ b/src/Orb.Tests/Models/NewUsageDiscountTest.cs @@ -416,6 +416,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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, + }; + + NewUsageDiscount copied = new(model); + + Assert.Equal(model, copied); + } } public class NewUsageDiscountAdjustmentTypeTest : TestBase @@ -618,6 +647,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewUsageDiscountFilter + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }; + + NewUsageDiscountFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class NewUsageDiscountFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/OtherSubLineItemTest.cs b/src/Orb.Tests/Models/OtherSubLineItemTest.cs index 66f19d4fe..698559aa9 100644 --- a/src/Orb.Tests/Models/OtherSubLineItemTest.cs +++ b/src/Orb.Tests/Models/OtherSubLineItemTest.cs @@ -99,6 +99,23 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new OtherSubLineItem + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + Name = "Tier One", + Quantity = 5, + Type = OtherSubLineItemType.Null, + }; + + OtherSubLineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class OtherSubLineItemTypeTest : TestBase diff --git a/src/Orb.Tests/Models/PackageConfigTest.cs b/src/Orb.Tests/Models/PackageConfigTest.cs index c5b03bab3..9df28ed11 100644 --- a/src/Orb.Tests/Models/PackageConfigTest.cs +++ b/src/Orb.Tests/Models/PackageConfigTest.cs @@ -58,4 +58,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageConfig { PackageAmount = "package_amount", PackageSize = 1 }; + + PackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/PaginationMetadataTest.cs b/src/Orb.Tests/Models/PaginationMetadataTest.cs index 2e0519289..23216581e 100644 --- a/src/Orb.Tests/Models/PaginationMetadataTest.cs +++ b/src/Orb.Tests/Models/PaginationMetadataTest.cs @@ -58,4 +58,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PaginationMetadata { HasMore = true, NextCursor = "next_cursor" }; + + PaginationMetadata copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/PerPriceCostTest.cs b/src/Orb.Tests/Models/PerPriceCostTest.cs index 7948f5db9..aaa74e604 100644 --- a/src/Orb.Tests/Models/PerPriceCostTest.cs +++ b/src/Orb.Tests/Models/PerPriceCostTest.cs @@ -1234,4 +1234,129 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PerPriceCost + { + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + PriceID = "price_id", + Subtotal = "subtotal", + Total = "total", + Quantity = 0, + }; + + PerPriceCost copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/PercentageDiscountIntervalTest.cs b/src/Orb.Tests/Models/PercentageDiscountIntervalTest.cs index 3b13bf6e8..f5315db7f 100644 --- a/src/Orb.Tests/Models/PercentageDiscountIntervalTest.cs +++ b/src/Orb.Tests/Models/PercentageDiscountIntervalTest.cs @@ -184,6 +184,32 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentageDiscountInterval + { + AppliesToPriceIntervalIds = ["string"], + DiscountType = PercentageDiscountIntervalDiscountType.Percentage, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = PercentageDiscountIntervalFilterField.PriceID, + Operator = PercentageDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + PercentageDiscount = 0.15, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + PercentageDiscountInterval copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentageDiscountIntervalDiscountTypeTest : TestBase @@ -328,6 +354,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentageDiscountIntervalFilter + { + Field = PercentageDiscountIntervalFilterField.PriceID, + Operator = PercentageDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }; + + PercentageDiscountIntervalFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentageDiscountIntervalFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/PercentageDiscountTest.cs b/src/Orb.Tests/Models/PercentageDiscountTest.cs index 5a6352ff4..c157e3c7f 100644 --- a/src/Orb.Tests/Models/PercentageDiscountTest.cs +++ b/src/Orb.Tests/Models/PercentageDiscountTest.cs @@ -236,6 +236,31 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentageDiscount + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }; + + PercentageDiscount copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentageDiscountDiscountTypeTest : TestBase @@ -382,6 +407,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentageDiscountFilter + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }; + + PercentageDiscountFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentageDiscountFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/PlanPhaseAmountDiscountAdjustmentTest.cs b/src/Orb.Tests/Models/PlanPhaseAmountDiscountAdjustmentTest.cs index c43b8acaa..ef0943fa7 100644 --- a/src/Orb.Tests/Models/PlanPhaseAmountDiscountAdjustmentTest.cs +++ b/src/Orb.Tests/Models/PlanPhaseAmountDiscountAdjustmentTest.cs @@ -198,6 +198,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhaseAmountDiscountAdjustment + { + ID = "id", + AdjustmentType = PlanPhaseAmountDiscountAdjustmentAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseAmountDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhaseAmountDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + PlanPhaseAmountDiscountAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhaseAmountDiscountAdjustmentAdjustmentTypeTest : TestBase @@ -344,6 +373,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhaseAmountDiscountAdjustmentFilter + { + Field = PlanPhaseAmountDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhaseAmountDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + PlanPhaseAmountDiscountAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhaseAmountDiscountAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/PlanPhaseMaximumAdjustmentTest.cs b/src/Orb.Tests/Models/PlanPhaseMaximumAdjustmentTest.cs index 994cc8e66..f909cbef8 100644 --- a/src/Orb.Tests/Models/PlanPhaseMaximumAdjustmentTest.cs +++ b/src/Orb.Tests/Models/PlanPhaseMaximumAdjustmentTest.cs @@ -198,6 +198,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhaseMaximumAdjustment + { + ID = "id", + AdjustmentType = PlanPhaseMaximumAdjustmentAdjustmentType.Maximum, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseMaximumAdjustmentFilterField.PriceID, + Operator = PlanPhaseMaximumAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + MaximumAmount = "maximum_amount", + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + PlanPhaseMaximumAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhaseMaximumAdjustmentAdjustmentTypeTest : TestBase @@ -342,6 +371,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhaseMaximumAdjustmentFilter + { + Field = PlanPhaseMaximumAdjustmentFilterField.PriceID, + Operator = PlanPhaseMaximumAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + PlanPhaseMaximumAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhaseMaximumAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/PlanPhaseMinimumAdjustmentTest.cs b/src/Orb.Tests/Models/PlanPhaseMinimumAdjustmentTest.cs index 396b61ad0..10b39aa3a 100644 --- a/src/Orb.Tests/Models/PlanPhaseMinimumAdjustmentTest.cs +++ b/src/Orb.Tests/Models/PlanPhaseMinimumAdjustmentTest.cs @@ -206,6 +206,36 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhaseMinimumAdjustment + { + ID = "id", + AdjustmentType = PlanPhaseMinimumAdjustmentAdjustmentType.Minimum, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseMinimumAdjustmentFilterField.PriceID, + Operator = PlanPhaseMinimumAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + PlanPhaseMinimumAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhaseMinimumAdjustmentAdjustmentTypeTest : TestBase @@ -350,6 +380,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhaseMinimumAdjustmentFilter + { + Field = PlanPhaseMinimumAdjustmentFilterField.PriceID, + Operator = PlanPhaseMinimumAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + PlanPhaseMinimumAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhaseMinimumAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/PlanPhasePercentageDiscountAdjustmentTest.cs b/src/Orb.Tests/Models/PlanPhasePercentageDiscountAdjustmentTest.cs index f51d6658b..2619328d4 100644 --- a/src/Orb.Tests/Models/PlanPhasePercentageDiscountAdjustmentTest.cs +++ b/src/Orb.Tests/Models/PlanPhasePercentageDiscountAdjustmentTest.cs @@ -204,6 +204,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhasePercentageDiscountAdjustment + { + ID = "id", + AdjustmentType = PlanPhasePercentageDiscountAdjustmentAdjustmentType.PercentageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhasePercentageDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhasePercentageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PercentageDiscount = 0, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + PlanPhasePercentageDiscountAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhasePercentageDiscountAdjustmentAdjustmentTypeTest : TestBase @@ -350,6 +379,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhasePercentageDiscountAdjustmentFilter + { + Field = PlanPhasePercentageDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhasePercentageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + PlanPhasePercentageDiscountAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhasePercentageDiscountAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/PlanPhaseUsageDiscountAdjustmentTest.cs b/src/Orb.Tests/Models/PlanPhaseUsageDiscountAdjustmentTest.cs index e5228b86a..d29771b2e 100644 --- a/src/Orb.Tests/Models/PlanPhaseUsageDiscountAdjustmentTest.cs +++ b/src/Orb.Tests/Models/PlanPhaseUsageDiscountAdjustmentTest.cs @@ -198,6 +198,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhaseUsageDiscountAdjustment + { + ID = "id", + AdjustmentType = PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }; + + PlanPhaseUsageDiscountAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhaseUsageDiscountAdjustmentAdjustmentTypeTest : TestBase @@ -344,6 +373,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhaseUsageDiscountAdjustmentFilter + { + Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }; + + PlanPhaseUsageDiscountAdjustmentFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPhaseUsageDiscountAdjustmentFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelResponseTest.cs b/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelResponseTest.cs index 2b7c8d031..96be03a8f 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelResponseTest.cs @@ -94,6 +94,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MigrationCancelResponse + { + ID = "id", + EffectiveTime = "2019-12-27", + PlanID = "plan_id", + Status = MigrationCancelResponseStatus.NotStarted, + }; + + MigrationCancelResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class MigrationCancelResponseEffectiveTimeTest : TestBase diff --git a/src/Orb.Tests/Models/Plans/Migrations/MigrationListPageResponseTest.cs b/src/Orb.Tests/Models/Plans/Migrations/MigrationListPageResponseTest.cs index 499fc7946..a6a9caa91 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationListPageResponseTest.cs @@ -146,4 +146,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MigrationListPageResponse + { + Data = + [ + new() + { + ID = "id", + EffectiveTime = "2019-12-27", + PlanID = "plan_id", + Status = MigrationListResponseStatus.NotStarted, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + MigrationListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/Migrations/MigrationListResponseTest.cs b/src/Orb.Tests/Models/Plans/Migrations/MigrationListResponseTest.cs index de2990917..4e42c3f39 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationListResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationListResponseTest.cs @@ -94,6 +94,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MigrationListResponse + { + ID = "id", + EffectiveTime = "2019-12-27", + PlanID = "plan_id", + Status = MigrationListResponseStatus.NotStarted, + }; + + MigrationListResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class MigrationListResponseEffectiveTimeTest : TestBase diff --git a/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveResponseTest.cs b/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveResponseTest.cs index a6159c831..a212e0f32 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveResponseTest.cs @@ -92,6 +92,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MigrationRetrieveResponse + { + ID = "id", + EffectiveTime = "2019-12-27", + PlanID = "plan_id", + Status = Status.NotStarted, + }; + + MigrationRetrieveResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class EffectiveTimeTest : TestBase diff --git a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs index a68a107fc..a8080c27a 100644 --- a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs @@ -1414,6 +1414,81 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Price + { + 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", + }, + }; + + Price copied = new(model); + + Assert.Equal(model, copied); + } } public class PricePriceTest : TestBase @@ -5300,6 +5375,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new 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 = Cadence.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", + }; + + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigTest : TestBase @@ -5412,6 +5541,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -5462,6 +5609,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class TierTest : TestBase @@ -5556,6 +5713,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -6172,6 +6339,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + Cadence = 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 = 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", + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationCadenceTest : TestBase @@ -6316,6 +6531,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationConfigTierTest : TestBase @@ -6388,6 +6616,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationConversionRateConfigTest : TestBase @@ -6990,38 +7232,90 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } -} - -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase -{ - [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(GroupedWithMinMaxThresholdsCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() + public void CopyConstructor_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] + var model = new GroupedWithMinMaxThresholds + { + Cadence = 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 = 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", + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(GroupedWithMinMaxThresholdsCadence 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(GroupedWithMinMaxThresholdsCadence.Annual)] [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] @@ -7142,6 +7436,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -7748,6 +8058,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = 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 = 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", + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -7900,6 +8262,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -8431,6 +8809,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Percent + { + Cadence = PercentCadence.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", + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentCadenceTest : TestBase @@ -8549,6 +8973,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentConversionRateConfigTest : TestBase @@ -9127,6 +9561,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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", + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputCadenceTest : TestBase @@ -9323,6 +9808,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputConversionRateConfigTest : TestBase @@ -9712,6 +10212,39 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Adjustment + { + 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, + }; + + Adjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class AdjustmentAdjustmentTest : TestBase @@ -10151,6 +10684,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPhase + { + Order = 0, + AlignBillingWithPhaseStartDate = true, + Duration = 1, + DurationUnit = DurationUnit.Daily, + }; + + PlanPhase copied = new(model); + + Assert.Equal(model, copied); + } } public class DurationUnitTest : TestBase diff --git a/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs b/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs index f963a44d7..07d8d076b 100644 --- a/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs @@ -1767,4 +1767,298 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanListPageResponse + { + Data = + [ + new() + { + ID = "id", + Adjustments = + [ + new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + BasePlan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + BasePlanID = "base_plan_id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", + 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", + }, + ExternalPlanID = "external_plan_id", + InvoicingCurrency = "invoicing_currency", + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + NetTerms = 0, + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + 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", + }, + Duration = 0, + DurationUnit = PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Product = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }, + Status = PlanStatus.Active, + TrialConfig = new() { TrialPeriod = 0, TrialPeriodUnit = TrialPeriodUnit.Days }, + Version = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + PlanListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/PlanTest.cs b/src/Orb.Tests/Models/Plans/PlanTest.cs index ff7d72d34..39e202821 100644 --- a/src/Orb.Tests/Models/Plans/PlanTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanTest.cs @@ -1780,6 +1780,290 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Plan + { + ID = "id", + Adjustments = + [ + new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + BasePlan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + BasePlanID = "base_plan_id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", + 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", + }, + ExternalPlanID = "external_plan_id", + InvoicingCurrency = "invoicing_currency", + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + NetTerms = 0, + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + 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", + }, + Duration = 0, + DurationUnit = PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Product = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }, + Status = PlanStatus.Active, + TrialConfig = new() { TrialPeriod = 0, TrialPeriodUnit = TrialPeriodUnit.Days }, + Version = 0, + }; + + Plan copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanAdjustmentTest : TestBase @@ -2154,6 +2438,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BasePlan + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }; + + BasePlan copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPlanPhaseTest : TestBase @@ -2546,6 +2845,70 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PlanPlanPhase + { + ID = "id", + Description = "description", + 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", + }, + Duration = 0, + DurationUnit = PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }; + + PlanPlanPhase copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanPlanPhaseDurationUnitTest : TestBase @@ -2687,6 +3050,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Product + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }; + + Product copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanStatusTest : TestBase @@ -2803,6 +3181,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TrialConfig { TrialPeriod = 0, TrialPeriodUnit = TrialPeriodUnit.Days }; + + TrialConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TrialPeriodUnitTest : TestBase diff --git a/src/Orb.Tests/Models/PriceIntervalTest.cs b/src/Orb.Tests/Models/PriceIntervalTest.cs index 6007a85c7..7098fcce2 100644 --- a/src/Orb.Tests/Models/PriceIntervalTest.cs +++ b/src/Orb.Tests/Models/PriceIntervalTest.cs @@ -879,4 +879,143 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceInterval + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }; + + PriceInterval copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/PriceTest.cs b/src/Orb.Tests/Models/PriceTest.cs index 27aeec1cc..9e2720f78 100644 --- a/src/Orb.Tests/Models/PriceTest.cs +++ b/src/Orb.Tests/Models/PriceTest.cs @@ -8618,6 +8618,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Unit + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + Unit copied = new(model); + + Assert.Equal(model, copied); + } } public class BillingModeTest : TestBase @@ -8834,6 +8948,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CompositePriceFilter + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + CompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class CompositePriceFilterFieldTest : TestBase @@ -10408,6 +10537,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tiered + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredBillingMode.InAdvance, + Cadence = TieredCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredCompositePriceFilterField.PriceID, + Operator = TieredCompositePriceFilterOperator.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 = TieredPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + Tiered copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredBillingModeTest : TestBase @@ -10624,6 +10879,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredCompositePriceFilter + { + Field = TieredCompositePriceFilterField.PriceID, + Operator = TieredCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + TieredCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredCompositePriceFilterFieldTest : TestBase @@ -12078,6 +12348,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Bulk + { + 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, + CompositePriceFilters = + [ + new() + { + Field = BulkCompositePriceFilterField.PriceID, + Operator = BulkCompositePriceFilterOperator.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 = BulkPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + Bulk copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkBillingModeTest : TestBase @@ -12294,6 +12678,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkCompositePriceFilter + { + Field = BulkCompositePriceFilterField.PriceID, + Operator = BulkCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + BulkCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkCompositePriceFilterFieldTest : TestBase @@ -13836,6 +14235,128 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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() + { + 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 = BulkWithFiltersPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersBillingModeTest : TestBase @@ -14012,6 +14533,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigFilterTest : TestBase @@ -14068,6 +14607,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfigFilter { PropertyKey = "x", PropertyValue = "x" }; + + BulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigTierTest : TestBase @@ -14184,6 +14733,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + BulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersCadenceTest : TestBase @@ -14342,6 +14905,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersCompositePriceFilter + { + Field = BulkWithFiltersCompositePriceFilterField.PriceID, + Operator = BulkWithFiltersCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + BulkWithFiltersCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersCompositePriceFilterFieldTest : TestBase @@ -15801,6 +16379,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Package + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = PackageBillingMode.InAdvance, + Cadence = PackageCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = PackageCompositePriceFilterField.PriceID, + Operator = PackageCompositePriceFilterOperator.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", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + PlanPhaseOrder = 0, + PriceType = PackagePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + Package copied = new(model); + + Assert.Equal(model, copied); + } } public class PackageBillingModeTest : TestBase @@ -16017,6 +16709,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageCompositePriceFilter + { + Field = PackageCompositePriceFilterField.PriceID, + Operator = PackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + PackageCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PackageCompositePriceFilterFieldTest : TestBase @@ -17517,6 +18224,125 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Matrix + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MatrixBillingMode.InAdvance, + Cadence = MatrixCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MatrixCompositePriceFilterField.PriceID, + Operator = MatrixCompositePriceFilterOperator.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" }, + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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 = MatrixPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + Matrix copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixBillingModeTest : TestBase @@ -17733,6 +18559,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixCompositePriceFilter + { + Field = MatrixCompositePriceFilterField.PriceID, + Operator = MatrixCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MatrixCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixCompositePriceFilterFieldTest : TestBase @@ -19277,6 +20118,128 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmount + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = ThresholdTotalAmountBillingMode.InAdvance, + Cadence = ThresholdTotalAmountCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = ThresholdTotalAmountCompositePriceFilterField.PriceID, + Operator = ThresholdTotalAmountCompositePriceFilterOperator.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 = 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"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + ThresholdTotalAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class ThresholdTotalAmountBillingModeTest : TestBase @@ -19491,6 +20454,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmountCompositePriceFilter + { + Field = ThresholdTotalAmountCompositePriceFilterField.PriceID, + Operator = ThresholdTotalAmountCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ThresholdTotalAmountCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class ThresholdTotalAmountCompositePriceFilterFieldTest : TestBase @@ -19914,6 +20892,24 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + ThresholdTotalAmountThresholdTotalAmountConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ThresholdTotalAmountThresholdTotalAmountConfigConsumptionTableTest : TestBase @@ -19988,6 +20984,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + ThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageTest : TestBase @@ -21275,6 +22285,128 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackage + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredPackageBillingMode.InAdvance, + Cadence = TieredPackageCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredPackageCompositePriceFilterField.PriceID, + Operator = TieredPackageCompositePriceFilterOperator.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 = 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"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + TieredPackage copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageBillingModeTest : TestBase @@ -21491,6 +22623,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageCompositePriceFilter + { + Field = TieredPackageCompositePriceFilterField.PriceID, + Operator = TieredPackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + TieredPackageCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageCompositePriceFilterFieldTest : TestBase @@ -21846,6 +22993,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + TieredPackageTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageTieredPackageConfigTierTest : TestBase @@ -21918,6 +23083,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithMinimumTest : TestBase @@ -23317,6 +24496,139 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredWithMinimumBillingMode.InAdvance, + Cadence = TieredWithMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredWithMinimumCompositePriceFilterOperator.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 = 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", + }, + }; + + TieredWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithMinimumBillingModeTest : TestBase @@ -23531,6 +24843,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumCompositePriceFilter + { + Field = TieredWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredWithMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + TieredWithMinimumCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithMinimumCompositePriceFilterFieldTest : TestBase @@ -24068,6 +25395,35 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + TieredWithMinimumTieredWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithMinimumTieredWithMinimumConfigTierTest : TestBase @@ -24148,6 +25504,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithMinimumTieredWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredTest : TestBase @@ -25435,6 +26806,128 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = GroupedTieredPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + GroupedTiered copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredBillingModeTest : TestBase @@ -25651,6 +27144,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredCompositePriceFilter + { + Field = GroupedTieredCompositePriceFilterField.PriceID, + Operator = GroupedTieredCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedTieredCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredCompositePriceFilterFieldTest : TestBase @@ -25946,6 +27454,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + GroupedTieredGroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredGroupedTieredConfigTierTest : TestBase @@ -26018,6 +27544,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredGroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + GroupedTieredGroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPriceTypeTest : TestBase @@ -27476,6 +29016,138 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + TieredPackageWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageWithMinimumBillingModeTest : TestBase @@ -27686,6 +29358,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumCompositePriceFilter + { + Field = TieredPackageWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredPackageWithMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + TieredPackageWithMinimumCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageWithMinimumCompositePriceFilterFieldTest : TestBase @@ -28105,6 +29792,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + TieredPackageWithMinimumTieredPackageWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageWithMinimumTieredPackageWithMinimumConfigTierTest : TestBase @@ -28187,6 +29902,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageWithMinimumTieredPackageWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class PackageWithAllocationTest : TestBase @@ -29450,6 +31180,125 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocation + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = PackageWithAllocationBillingMode.InAdvance, + Cadence = PackageWithAllocationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = PackageWithAllocationCompositePriceFilterField.PriceID, + Operator = PackageWithAllocationCompositePriceFilterOperator.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", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + PlanPhaseOrder = 0, + PriceType = PackageWithAllocationPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + PackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class PackageWithAllocationBillingModeTest : TestBase @@ -29662,6 +31511,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationCompositePriceFilter + { + Field = PackageWithAllocationCompositePriceFilterField.PriceID, + Operator = PackageWithAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + PackageWithAllocationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PackageWithAllocationCompositePriceFilterFieldTest : TestBase @@ -29939,6 +31803,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + PackageWithAllocationPackageWithAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PackageWithAllocationPriceTypeTest : TestBase @@ -31212,6 +33091,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercent + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = UnitWithPercentBillingMode.InAdvance, + Cadence = UnitWithPercentCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = UnitWithPercentCompositePriceFilterField.PriceID, + Operator = UnitWithPercentCompositePriceFilterOperator.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 = UnitWithPercentPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + UnitWithPercent copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithPercentBillingModeTest : TestBase @@ -31428,6 +33421,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentCompositePriceFilter + { + Field = UnitWithPercentCompositePriceFilterField.PriceID, + Operator = UnitWithPercentCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + UnitWithPercentCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithPercentCompositePriceFilterFieldTest : TestBase @@ -31751,6 +33759,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + UnitWithPercentUnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithAllocationTest : TestBase @@ -33020,6 +35042,126 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocation + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MatrixWithAllocationBillingMode.InAdvance, + Cadence = MatrixWithAllocationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MatrixWithAllocationCompositePriceFilterField.PriceID, + Operator = MatrixWithAllocationCompositePriceFilterOperator.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" }, + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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 = MatrixWithAllocationPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + MatrixWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithAllocationBillingModeTest : TestBase @@ -33234,6 +35376,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationCompositePriceFilter + { + Field = MatrixWithAllocationCompositePriceFilterField.PriceID, + Operator = MatrixWithAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MatrixWithAllocationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithAllocationCompositePriceFilterFieldTest : TestBase @@ -34714,6 +36871,122 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.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 = TieredWithProrationPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationBillingModeTest : TestBase @@ -34928,6 +37201,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationCompositePriceFilter + { + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + TieredWithProrationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationCompositePriceFilterFieldTest : TestBase @@ -35257,6 +37545,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationTieredWithProrationConfigTierTest : TestBase @@ -35331,6 +37632,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithProrationTest : TestBase @@ -36544,6 +38859,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProration + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.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 = UnitWithProrationPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitWithProrationConfig = new("unit_amount"), + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + UnitWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithProrationBillingModeTest : TestBase @@ -36758,6 +39187,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationCompositePriceFilter + { + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + UnitWithProrationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithProrationCompositePriceFilterFieldTest : TestBase @@ -37061,6 +39505,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + + UnitWithProrationUnitWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedAllocationTest : TestBase @@ -38320,6 +40774,125 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocation + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.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, + 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() + { + 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 = GroupedAllocationPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + GroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedAllocationBillingModeTest : TestBase @@ -38534,6 +41107,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationCompositePriceFilter + { + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedAllocationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedAllocationCompositePriceFilterFieldTest : TestBase @@ -38805,6 +41393,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + GroupedAllocationGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedAllocationPriceTypeTest : TestBase @@ -40124,6 +42727,125 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProration + { + 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, + CompositePriceFilters = + [ + new() + { + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.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 = BulkWithProrationPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + BulkWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationBillingModeTest : TestBase @@ -40276,6 +42998,23 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithProrationBulkWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationBulkWithProrationConfigTierTest : TestBase @@ -40392,6 +43131,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + BulkWithProrationBulkWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationCadenceTest : TestBase @@ -40550,6 +43303,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationCompositePriceFilter + { + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + BulkWithProrationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationCompositePriceFilterFieldTest : TestBase @@ -42072,6 +44840,125 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, + Cadence = GroupedWithProratedMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.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, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + 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 = GroupedWithProratedMinimumPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + GroupedWithProratedMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithProratedMinimumBillingModeTest : TestBase @@ -42284,6 +45171,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumCompositePriceFilter + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedWithProratedMinimumCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithProratedMinimumCompositePriceFilterFieldTest : TestBase @@ -42565,6 +45467,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + GroupedWithProratedMinimumGroupedWithProratedMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithProratedMinimumPriceTypeTest : TestBase @@ -43982,6 +46899,134 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, + Cadence = GroupedWithMeteredMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.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, + 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() + { + 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 = GroupedWithMeteredMinimumPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + GroupedWithMeteredMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumBillingModeTest : TestBase @@ -44194,6 +47239,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumCompositePriceFilter + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedWithMeteredMinimumCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumCompositePriceFilterFieldTest : TestBase @@ -44537,6 +47597,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }], + }; + + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorTest : TestBase @@ -44611,6 +47692,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountTest : TestBase @@ -44685,6 +47780,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumPriceTypeTest : TestBase @@ -46022,6 +49131,126 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholds + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.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, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + 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 = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsBillingModeTest : TestBase @@ -46234,6 +49463,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsCompositePriceFilter + { + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedWithMinMaxThresholdsCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCompositePriceFilterFieldTest : TestBase @@ -46521,6 +49765,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsPriceTypeTest : TestBase @@ -47910,6 +51170,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayName + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.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" }, + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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 = MatrixWithDisplayNamePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + MatrixWithDisplayName copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameBillingModeTest : TestBase @@ -48122,6 +51508,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameCompositePriceFilter + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MatrixWithDisplayNameCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameCompositePriceFilterFieldTest : TestBase @@ -48447,6 +51848,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + MatrixWithDisplayNameMatrixWithDisplayNameConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountTest : TestBase @@ -48529,6 +51952,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNamePriceTypeTest : TestBase @@ -49886,6 +53324,129 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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 }, + 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 = GroupedTieredPackagePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + GroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageBillingModeTest : TestBase @@ -50100,6 +53661,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageCompositePriceFilter + { + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedTieredPackageCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageCompositePriceFilterFieldTest : TestBase @@ -50407,6 +53983,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + GroupedTieredPackageGroupedTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageGroupedTieredPackageConfigTierTest : TestBase @@ -50481,6 +54076,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + GroupedTieredPackageGroupedTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackagePriceTypeTest : TestBase @@ -51842,6 +55451,129 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackage + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.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" }, + 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"], + 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 = MaxGroupTieredPackagePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + MaxGroupTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackageBillingModeTest : TestBase @@ -52054,6 +55786,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageCompositePriceFilter + { + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MaxGroupTieredPackageCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackageCompositePriceFilterFieldTest : TestBase @@ -52363,6 +56110,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + MaxGroupTieredPackageMaxGroupTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackageMaxGroupTieredPackageConfigTierTest : TestBase @@ -52437,6 +56203,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + MaxGroupTieredPackageMaxGroupTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackagePriceTypeTest : TestBase @@ -53866,6 +57646,135 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.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 = 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"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + ScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingBillingModeTest : TestBase @@ -54080,6 +57989,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingCompositePriceFilter + { + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ScalableMatrixWithUnitPricingCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingCompositePriceFilterFieldTest : TestBase @@ -54587,6 +58511,31 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest @@ -54732,6 +58681,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingTest : TestBase @@ -56133,6 +60099,138 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.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 = 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"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + ScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingBillingModeTest : TestBase @@ -56347,6 +60445,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingCompositePriceFilter + { + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ScalableMatrixWithTieredPricingCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingCompositePriceFilterFieldTest : TestBase @@ -56892,6 +61005,34 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest @@ -57037,6 +61178,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierTest : TestBase @@ -57111,6 +61269,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkTest : TestBase @@ -58444,6 +62618,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulk + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.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"], + }, + ], + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + 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 = CumulativeGroupedBulkPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + + CumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkBillingModeTest : TestBase @@ -58656,6 +62956,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkCompositePriceFilter + { + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + CumulativeGroupedBulkCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkCompositePriceFilterFieldTest : TestBase @@ -58981,6 +63296,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + CumulativeGroupedBulkCumulativeGroupedBulkConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueTest : TestBase @@ -59063,6 +63400,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkPriceTypeTest : TestBase @@ -60165,240 +64517,360 @@ public void OptionalNullablePropertiesUnsetValidation_Works() 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() + }; + + 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(); + } + + [Fact] + public void CopyConstructor_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 = new() { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", }, - 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")); - } + CumulativeGroupedAllocation copied = new(model); - [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(); + Assert.Equal(model, copied); } } @@ -60612,6 +65084,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationCompositePriceFilter + { + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + CumulativeGroupedAllocationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCompositePriceFilterFieldTest : TestBase @@ -60899,6 +65386,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationPriceTypeTest : TestBase @@ -62170,6 +66673,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }, + }; + + MinimumComposite copied = new(model); + + Assert.Equal(model, copied); + } } public class MinimumCompositeBillingModeTest : TestBase @@ -62386,6 +67003,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeCompositePriceFilter + { + Field = MinimumCompositeCompositePriceFilterField.PriceID, + Operator = MinimumCompositeCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MinimumCompositeCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MinimumCompositeCompositePriceFilterFieldTest : TestBase @@ -62695,6 +67327,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + MinimumCompositeMinimumCompositeConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MinimumCompositePriceTypeTest : TestBase @@ -63955,6 +68601,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }, + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentBillingModeTest : TestBase @@ -64171,6 +68931,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentCompositePriceFilter + { + Field = PercentCompositePriceFilterField.PriceID, + Operator = PercentCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + PercentCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentCompositePriceFilterFieldTest : TestBase @@ -64416,6 +69191,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentPriceTypeTest : TestBase @@ -65385,126 +70170,355 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() PlanPhaseOrder = 0, PriceType = EventOutputPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } + }; + + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = 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, + 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", + }, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + 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 = EventOutputPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = 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, + 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", + }, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + 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 = EventOutputPriceType.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 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, + 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", + }, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + 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 = EventOutputPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = 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, - 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", - }, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - 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 = EventOutputPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = null, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void CopyConstructor_Works() { var model = new EventOutput { @@ -65610,126 +70624,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() PlanPhaseOrder = 0, PriceType = EventOutputPriceType.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 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, - 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", - }, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - 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() + DimensionalPriceConfiguration = new() { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = EventOutputPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - - DimensionalPriceConfiguration = null, }; - model.Validate(); + EventOutput copied = new(model); + + Assert.Equal(model, copied); } } @@ -65947,6 +70851,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputCompositePriceFilter + { + Field = EventOutputCompositePriceFilterField.PriceID, + Operator = EventOutputCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + EventOutputCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputCompositePriceFilterFieldTest : TestBase @@ -66268,6 +71187,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputPriceTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Prices/EvaluatePriceGroupTest.cs b/src/Orb.Tests/Models/Prices/EvaluatePriceGroupTest.cs index f2c0da27e..4c15fb7ae 100644 --- a/src/Orb.Tests/Models/Prices/EvaluatePriceGroupTest.cs +++ b/src/Orb.Tests/Models/Prices/EvaluatePriceGroupTest.cs @@ -91,6 +91,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EvaluatePriceGroup + { + Amount = "amount", + GroupingValues = ["string"], + Quantity = 0, + }; + + EvaluatePriceGroup copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupingValueTest : TestBase diff --git a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs index a5714c815..3dfa107ba 100644 --- a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs @@ -3920,6 +3920,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new 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 = Cadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + 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" } }, + }; + + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigTest : TestBase @@ -4032,6 +4085,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -4082,6 +4153,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class TierTest : TestBase @@ -4176,6 +4257,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -4826,6 +4917,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Currency = "currency", + 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 = 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" } }, + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -4978,6 +5120,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -5568,6 +5726,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + 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" } }, + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -5720,6 +5929,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -6235,6 +6460,51 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + 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" } }, + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentCadenceTest : TestBase @@ -6353,6 +6623,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentConversionRateConfigTest : TestBase @@ -6915,6 +7195,56 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + 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" } }, + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputCadenceTest : TestBase @@ -7111,6 +7441,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs index a5fa9e783..f1af1bf64 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs @@ -985,6 +985,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluation + { + 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", + }; + + PriceEvaluation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceTest : TestBase @@ -4712,6 +4766,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + 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" } }, + }; + + PriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase @@ -4830,6 +4937,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + PriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase @@ -4904,6 +5029,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + PriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase @@ -5028,6 +5167,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + PriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceBulkWithFiltersCadenceTest : TestBase @@ -5684,6 +5837,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, + Currency = "currency", + 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 = 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" } }, + }; + + PriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceGroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -5836,6 +6040,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -6428,6 +6648,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + 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" } }, + }; + + PriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceCumulativeGroupedAllocationCadenceTest : TestBase @@ -6580,6 +6851,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -7098,6 +7385,51 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + 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" } }, + }; + + PricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class PricePercentCadenceTest : TestBase @@ -7216,6 +7548,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePercentPercentConfig { Percent = 0 }; + + PricePercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PricePercentConversionRateConfigTest : TestBase @@ -7778,6 +8120,56 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + 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" } }, + }; + + PriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEventOutputCadenceTest : TestBase @@ -7974,6 +8366,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + PriceEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEventOutputConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleResponseTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleResponseTest.cs index 3009ad505..2eab00b4a 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleResponseTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleResponseTest.cs @@ -183,6 +183,37 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluateMultipleResponse + { + Data = + [ + new() + { + Currency = "currency", + PriceGroups = + [ + new() + { + Amount = "amount", + GroupingValues = ["string"], + Quantity = 0, + }, + ], + ExternalPriceID = "external_price_id", + InlinePriceIndex = 0, + PriceID = "price_id", + }, + ], + }; + + PriceEvaluateMultipleResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class DataTest : TestBase @@ -427,4 +458,29 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Data + { + Currency = "currency", + PriceGroups = + [ + new() + { + Amount = "amount", + GroupingValues = ["string"], + Quantity = 0, + }, + ], + ExternalPriceID = "external_price_id", + InlinePriceIndex = 0, + PriceID = "price_id", + }; + + Data copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs index 261889130..5484d0e38 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs @@ -649,6 +649,26 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Event + { + 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", + }; + + Event copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationTest : TestBase @@ -1257,6 +1277,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluation + { + 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", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceTest : TestBase @@ -5200,6 +5273,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters + { + 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 = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTest @@ -5325,6 +5452,26 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilterTest @@ -5404,6 +5551,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilter copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTierTest @@ -5537,6 +5700,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersCadenceTest @@ -6248,6 +6427,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadenceTest @@ -6452,6 +6685,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigTest @@ -7070,6 +7321,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceTest @@ -7274,6 +7579,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigTest @@ -7805,6 +8128,51 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent + { + Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadenceTest : TestBase @@ -7939,6 +8307,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig + { + Percent = 0, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentConversionRateConfigTest @@ -8520,6 +8903,56 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput + { + Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputCadenceTest : TestBase @@ -8739,6 +9172,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputEventOutputConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputConversionRateConfigTest diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsResponseTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsResponseTest.cs index 9f4bc31a7..20e9d5b48 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsResponseTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsResponseTest.cs @@ -183,6 +183,37 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsResponse + { + Data = + [ + new() + { + Currency = "currency", + PriceGroups = + [ + new() + { + Amount = "amount", + GroupingValues = ["string"], + Quantity = 0, + }, + ], + ExternalPriceID = "external_price_id", + InlinePriceIndex = 0, + PriceID = "price_id", + }, + ], + }; + + PriceEvaluatePreviewEventsResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsResponseDataTest : TestBase @@ -433,4 +464,29 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsResponseData + { + Currency = "currency", + PriceGroups = + [ + new() + { + Amount = "amount", + GroupingValues = ["string"], + Quantity = 0, + }, + ], + ExternalPriceID = "external_price_id", + InlinePriceIndex = 0, + PriceID = "price_id", + }; + + PriceEvaluatePreviewEventsResponseData copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateResponseTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateResponseTest.cs index 5e99a9846..9170a216f 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateResponseTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateResponseTest.cs @@ -123,4 +123,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluateResponse + { + Data = + [ + new() + { + Amount = "amount", + GroupingValues = ["string"], + Quantity = 0, + }, + ], + }; + + PriceEvaluateResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs b/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs index 2975d082f..6b7933e66 100644 --- a/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs @@ -789,4 +789,134 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceListPageResponse + { + Data = + [ + new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + PriceListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/SharedCreditNoteTest.cs b/src/Orb.Tests/Models/SharedCreditNoteTest.cs index 88b0b8583..d3c9f33a1 100644 --- a/src/Orb.Tests/Models/SharedCreditNoteTest.cs +++ b/src/Orb.Tests/Models/SharedCreditNoteTest.cs @@ -803,6 +803,86 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SharedCreditNote + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartTimeInclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }; + + SharedCreditNote copied = new(model); + + Assert.Equal(model, copied); + } } public class SharedCreditNoteLineItemTest : TestBase @@ -1361,6 +1441,48 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SharedCreditNoteLineItem + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartTimeInclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + SharedCreditNoteLineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class DiscountTest : TestBase @@ -1552,6 +1674,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Discount + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }; + + Discount copied = new(model); + + Assert.Equal(model, copied); + } } public class DiscountDiscountTypeTest : TestBase @@ -1782,6 +1923,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaximumAmountAdjustment + { + AmountApplied = "amount_applied", + DiscountType = MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }; + + MaximumAmountAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class MaximumAmountAdjustmentDiscountTypeTest : TestBase @@ -1890,6 +2048,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AppliesToPrice { ID = "id", Name = "name" }; + + AppliesToPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class ReasonTest : TestBase @@ -2188,6 +2356,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SharedCreditNoteDiscount + { + AmountApplied = "amount_applied", + DiscountType = SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }; + + SharedCreditNoteDiscount copied = new(model); + + Assert.Equal(model, copied); + } } public class SharedCreditNoteDiscountDiscountTypeTest : TestBase @@ -2296,4 +2481,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SharedCreditNoteDiscountAppliesToPrice { ID = "id", Name = "name" }; + + SharedCreditNoteDiscountAppliesToPrice copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/SharedTierTest.cs b/src/Orb.Tests/Models/SharedTierTest.cs index 4ef159a6d..8bbb702d4 100644 --- a/src/Orb.Tests/Models/SharedTierTest.cs +++ b/src/Orb.Tests/Models/SharedTierTest.cs @@ -128,4 +128,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SharedTier + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }; + + SharedTier copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/SharedTieredConversionRateConfigTest.cs b/src/Orb.Tests/Models/SharedTieredConversionRateConfigTest.cs index 1f6345e7d..2640008de 100644 --- a/src/Orb.Tests/Models/SharedTieredConversionRateConfigTest.cs +++ b/src/Orb.Tests/Models/SharedTieredConversionRateConfigTest.cs @@ -129,6 +129,29 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SharedTieredConversionRateConfig + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + + SharedTieredConversionRateConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ConversionRateTypeTest : TestBase diff --git a/src/Orb.Tests/Models/SharedUnitConversionRateConfigTest.cs b/src/Orb.Tests/Models/SharedUnitConversionRateConfigTest.cs index 0691ae9b5..2cde419fd 100644 --- a/src/Orb.Tests/Models/SharedUnitConversionRateConfigTest.cs +++ b/src/Orb.Tests/Models/SharedUnitConversionRateConfigTest.cs @@ -81,6 +81,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SharedUnitConversionRateConfig + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + + SharedUnitConversionRateConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class SharedUnitConversionRateConfigConversionRateTypeTest : TestBase diff --git a/src/Orb.Tests/Models/SubLineItemGroupingTest.cs b/src/Orb.Tests/Models/SubLineItemGroupingTest.cs index a5b5e35f6..73730e3e3 100644 --- a/src/Orb.Tests/Models/SubLineItemGroupingTest.cs +++ b/src/Orb.Tests/Models/SubLineItemGroupingTest.cs @@ -58,4 +58,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubLineItemGrouping { Key = "region", Value = "west" }; + + SubLineItemGrouping copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/SubLineItemMatrixConfigTest.cs b/src/Orb.Tests/Models/SubLineItemMatrixConfigTest.cs index 4cc0e0ff2..24d290ffc 100644 --- a/src/Orb.Tests/Models/SubLineItemMatrixConfigTest.cs +++ b/src/Orb.Tests/Models/SubLineItemMatrixConfigTest.cs @@ -63,4 +63,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubLineItemMatrixConfig { DimensionValues = ["string"] }; + + SubLineItemMatrixConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/SubscriptionChangeMinifiedTest.cs b/src/Orb.Tests/Models/SubscriptionChangeMinifiedTest.cs index 1a8f1bf26..34d733765 100644 --- a/src/Orb.Tests/Models/SubscriptionChangeMinifiedTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChangeMinifiedTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionChangeMinified { ID = "id" }; + + SubscriptionChangeMinified copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs index d8d2775ac..b1bc9ed9e 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs @@ -11615,6 +11615,1513 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MutatedSubscription + { + ID = "id", + ActivePlanPhaseOrder = 0, + AdjustmentIntervals = + [ + new() + { + ID = "id", + Adjustment = new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AutoCollection = true, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, + }, + BillingCycleDay = 1, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Customer = new() + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = [new() { ID = "id", ExternalCustomerID = "external_customer_id" }], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }, + DefaultInvoiceMemo = "default_invoice_memo", + DiscountIntervals = + [ + new Models::AmountDiscountInterval() + { + AmountDiscount = "amount_discount", + AppliesToPriceIntervalIds = ["string"], + DiscountType = Models::AmountDiscountIntervalDiscountType.Amount, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::AmountDiscountIntervalFilterField.PriceID, + Operator = Models::AmountDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FixedFeeQuantitySchedule = + [ + new() + { + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + InvoicingThreshold = "invoicing_threshold", + MaximumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::MaximumIntervalFilterField.PriceID, + Operator = Models::MaximumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + MinimumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::MinimumIntervalFilterField.PriceID, + Operator = Models::MinimumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Name = "name", + NetTerms = 0, + PendingSubscriptionChange = new("id"), + Plan = new() + { + ID = "id", + Adjustments = + [ + new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + BasePlan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + BasePlanID = "base_plan_id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", + 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", + }, + ExternalPlanID = "external_plan_id", + InvoicingCurrency = "invoicing_currency", + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + NetTerms = 0, + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + 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", + }, + Duration = 0, + DurationUnit = PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Product = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }, + Status = PlanStatus.Active, + TrialConfig = new() { TrialPeriod = 0, TrialPeriodUnit = TrialPeriodUnit.Days }, + Version = 0, + }, + PriceIntervals = + [ + new() + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }, + ], + RedeemedCoupon = new() + { + CouponID = "coupon_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = MutatedSubscriptionStatus.Active, + TrialInfo = new(DateTimeOffset.Parse("2019-12-27T18:11:19.117Z")), + ChangedResources = new() + { + CreatedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartTimeInclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + CreatedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceSource.Subscription, + IsPayableNow = true, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::Status.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + VoidedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartTimeInclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + VoidedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + Models::InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + Models::InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + }, + }; + + MutatedSubscription copied = new(model); + + Assert.Equal(model, copied); + } } public class DiscountIntervalTest : TestBase diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs index 182a97293..22e1e7e7f 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs @@ -15572,6 +15572,1570 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionChangeApplyResponse + { + ID = "id", + ChangeType = "change_type", + ExpirationTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = SubscriptionChangeApplyResponseStatus.Pending, + Subscription = new() + { + ID = "id", + ActivePlanPhaseOrder = 0, + AdjustmentIntervals = + [ + new() + { + ID = "id", + Adjustment = new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AutoCollection = true, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, + }, + BillingCycleDay = 1, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Customer = new() + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = + [ + new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + ], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }, + DefaultInvoiceMemo = "default_invoice_memo", + DiscountIntervals = + [ + new Models::AmountDiscountInterval() + { + AmountDiscount = "amount_discount", + AppliesToPriceIntervalIds = ["string"], + DiscountType = Models::AmountDiscountIntervalDiscountType.Amount, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::AmountDiscountIntervalFilterField.PriceID, + Operator = Models::AmountDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FixedFeeQuantitySchedule = + [ + new() + { + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + InvoicingThreshold = "invoicing_threshold", + MaximumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::MaximumIntervalFilterField.PriceID, + Operator = Models::MaximumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + MinimumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::MinimumIntervalFilterField.PriceID, + Operator = Models::MinimumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Name = "name", + NetTerms = 0, + PendingSubscriptionChange = new("id"), + Plan = new() + { + ID = "id", + Adjustments = + [ + new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + BasePlan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + BasePlanID = "base_plan_id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", + 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", + }, + ExternalPlanID = "external_plan_id", + InvoicingCurrency = "invoicing_currency", + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + NetTerms = 0, + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + 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", + }, + Duration = 0, + DurationUnit = PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Product = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }, + Status = PlanStatus.Active, + TrialConfig = new() { TrialPeriod = 0, TrialPeriodUnit = TrialPeriodUnit.Days }, + Version = 0, + }, + PriceIntervals = + [ + new() + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }, + ], + RedeemedCoupon = new() + { + CouponID = "coupon_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = MutatedSubscriptionStatus.Active, + TrialInfo = new(DateTimeOffset.Parse("2019-12-27T18:11:19.117Z")), + ChangedResources = new() + { + CreatedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + StartTimeInclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + CreatedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceSource.Subscription, + IsPayableNow = true, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = + Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = + Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = + Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::Status.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + VoidedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + StartTimeInclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + VoidedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + Models::InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = + Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = + Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = + Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + Models::InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + }, + }, + AppliedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + BillingCycleAlignment = "billing_cycle_alignment", + CancelledAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ChangeOption = "change_option", + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanID = "plan_id", + }; + + SubscriptionChangeApplyResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionChangeApplyResponseStatusTest : TestBase diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs index 90bc16c7c..8c315d911 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs @@ -15572,6 +15572,1570 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionChangeCancelResponse + { + ID = "id", + ChangeType = "change_type", + ExpirationTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = SubscriptionChangeCancelResponseStatus.Pending, + Subscription = new() + { + ID = "id", + ActivePlanPhaseOrder = 0, + AdjustmentIntervals = + [ + new() + { + ID = "id", + Adjustment = new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AutoCollection = true, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, + }, + BillingCycleDay = 1, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Customer = new() + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = + [ + new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + ], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }, + DefaultInvoiceMemo = "default_invoice_memo", + DiscountIntervals = + [ + new Models::AmountDiscountInterval() + { + AmountDiscount = "amount_discount", + AppliesToPriceIntervalIds = ["string"], + DiscountType = Models::AmountDiscountIntervalDiscountType.Amount, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::AmountDiscountIntervalFilterField.PriceID, + Operator = Models::AmountDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FixedFeeQuantitySchedule = + [ + new() + { + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + InvoicingThreshold = "invoicing_threshold", + MaximumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::MaximumIntervalFilterField.PriceID, + Operator = Models::MaximumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + MinimumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::MinimumIntervalFilterField.PriceID, + Operator = Models::MinimumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Name = "name", + NetTerms = 0, + PendingSubscriptionChange = new("id"), + Plan = new() + { + ID = "id", + Adjustments = + [ + new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + BasePlan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + BasePlanID = "base_plan_id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", + 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", + }, + ExternalPlanID = "external_plan_id", + InvoicingCurrency = "invoicing_currency", + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + NetTerms = 0, + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + 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", + }, + Duration = 0, + DurationUnit = PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Product = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }, + Status = PlanStatus.Active, + TrialConfig = new() { TrialPeriod = 0, TrialPeriodUnit = TrialPeriodUnit.Days }, + Version = 0, + }, + PriceIntervals = + [ + new() + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }, + ], + RedeemedCoupon = new() + { + CouponID = "coupon_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = MutatedSubscriptionStatus.Active, + TrialInfo = new(DateTimeOffset.Parse("2019-12-27T18:11:19.117Z")), + ChangedResources = new() + { + CreatedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + StartTimeInclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + CreatedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceSource.Subscription, + IsPayableNow = true, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = + Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = + Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = + Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::Status.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + VoidedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + StartTimeInclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + VoidedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + Models::InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = + Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = + Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = + Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + Models::InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + }, + }, + AppliedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + BillingCycleAlignment = "billing_cycle_alignment", + CancelledAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ChangeOption = "change_option", + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanID = "plan_id", + }; + + SubscriptionChangeCancelResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionChangeCancelResponseStatusTest : TestBase diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListPageResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListPageResponseTest.cs index f8e9f4cf5..5b974c457 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListPageResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListPageResponseTest.cs @@ -159,4 +159,29 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionChangeListPageResponse + { + Data = + [ + new() + { + ID = "id", + ExpirationTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = SubscriptionChangeListResponseStatus.Pending, + SubscriptionID = "subscription_id", + AppliedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CancelledAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + SubscriptionChangeListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListResponseTest.cs index c03796879..85cad03e3 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListResponseTest.cs @@ -178,6 +178,24 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionChangeListResponse + { + ID = "id", + ExpirationTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = SubscriptionChangeListResponseStatus.Pending, + SubscriptionID = "subscription_id", + AppliedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CancelledAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + SubscriptionChangeListResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionChangeListResponseStatusTest : TestBase diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs index 85d31234a..55c63020f 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs @@ -15572,6 +15572,1570 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionChangeRetrieveResponse + { + ID = "id", + ChangeType = "change_type", + ExpirationTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = SubscriptionChangeRetrieveResponseStatus.Pending, + Subscription = new() + { + ID = "id", + ActivePlanPhaseOrder = 0, + AdjustmentIntervals = + [ + new() + { + ID = "id", + Adjustment = new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AutoCollection = true, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, + }, + BillingCycleDay = 1, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Customer = new() + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = + [ + new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + ], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }, + DefaultInvoiceMemo = "default_invoice_memo", + DiscountIntervals = + [ + new Models::AmountDiscountInterval() + { + AmountDiscount = "amount_discount", + AppliesToPriceIntervalIds = ["string"], + DiscountType = Models::AmountDiscountIntervalDiscountType.Amount, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::AmountDiscountIntervalFilterField.PriceID, + Operator = Models::AmountDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FixedFeeQuantitySchedule = + [ + new() + { + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + InvoicingThreshold = "invoicing_threshold", + MaximumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::MaximumIntervalFilterField.PriceID, + Operator = Models::MaximumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + MinimumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Models::MinimumIntervalFilterField.PriceID, + Operator = Models::MinimumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Name = "name", + NetTerms = 0, + PendingSubscriptionChange = new("id"), + Plan = new() + { + ID = "id", + Adjustments = + [ + new Models::PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + BasePlan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + BasePlanID = "base_plan_id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", + 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", + }, + ExternalPlanID = "external_plan_id", + InvoicingCurrency = "invoicing_currency", + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + NetTerms = 0, + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + 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", + }, + Duration = 0, + DurationUnit = PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Product = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }, + Status = PlanStatus.Active, + TrialConfig = new() { TrialPeriod = 0, TrialPeriodUnit = TrialPeriodUnit.Days }, + Version = 0, + }, + PriceIntervals = + [ + new() + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }, + ], + RedeemedCoupon = new() + { + CouponID = "coupon_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = MutatedSubscriptionStatus.Active, + TrialInfo = new(DateTimeOffset.Parse("2019-12-27T18:11:19.117Z")), + ChangedResources = new() + { + CreatedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + StartTimeInclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + CreatedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = Models::Action.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::Type.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceSource.Subscription, + IsPayableNow = true, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = + Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = + Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = + Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = Models::PaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::Status.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + VoidedCreditNotes = + [ + new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditNoteNumber = "credit_note_number", + CreditNotePdf = "credit_note_pdf", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + InvoiceID = "invoice_id", + LineItems = + [ + new() + { + ID = "id", + Amount = "amount", + ItemID = "item_id", + Name = "name", + Quantity = 0, + Subtotal = "subtotal", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + Discounts = + [ + new() + { + ID = "id", + AmountApplied = "amount_applied", + AppliesToPriceIds = ["string"], + DiscountType = Models::DiscountDiscountType.Percentage, + PercentageDiscount = 0, + AmountDiscount = "amount_discount", + Reason = "reason", + }, + ], + EndTimeExclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + StartTimeInclusive = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + ], + MaximumAmountAdjustment = new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::MaximumAmountAdjustmentDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + Memo = "memo", + MinimumAmountRefunded = "minimum_amount_refunded", + Reason = Models::Reason.Duplicate, + Subtotal = "subtotal", + Total = "total", + Type = Models::SharedCreditNoteType.Refund, + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Discounts = + [ + new() + { + AmountApplied = "amount_applied", + DiscountType = + Models::SharedCreditNoteDiscountDiscountType.Percentage, + PercentageDiscount = 0, + AppliesToPrices = [new() { ID = "id", Name = "name" }], + Reason = "reason", + }, + ], + }, + ], + VoidedInvoices = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + Models::InvoiceCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = Models::InvoiceCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + 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 = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = Models::InvoiceInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + ID = "id", + AdjustedSubtotal = "5.00", + Adjustments = + [ + new Models::MonetaryUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + Models::MonetaryUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + Amount = "amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = + Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + Amount = "7.00", + CreditsApplied = "6.00", + EndDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + Filter = "filter", + Grouping = "grouping", + Name = "Fixed Fee", + PartiallyInvoicedAmount = "4.00", + Price = new Models::Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + BillingMode = Models::BillingMode.InAdvance, + Cadence = Models::UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = Models::CompositePriceFilterField.PriceID, + Operator = + Models::CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::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 = + Models::CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + 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", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::DurationUnit.Day, + }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = + Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() + { + { "foo", "string" }, + }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = + Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = Models::UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + Quantity = 1, + StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), + SubLineItems = + [ + new Models::MatrixSubLineItem() + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + MatrixConfig = new(["string"]), + Name = "Tier One", + Quantity = 5, + Type = Models::MatrixSubLineItemType.Matrix, + ScaledQuantity = 0, + }, + ], + Subtotal = "9.00", + TaxAmounts = + [ + new() + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }, + ], + UsageCustomerIds = ["string"], + }, + ], + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + Models::InvoicePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = Models::InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + Subtotal = "8.00", + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + }, + }, + AppliedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + BillingCycleAlignment = "billing_cycle_alignment", + CancelledAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ChangeOption = "change_option", + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanID = "plan_id", + }; + + SubscriptionChangeRetrieveResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionChangeRetrieveResponseStatusTest : TestBase diff --git a/src/Orb.Tests/Models/SubscriptionMinifiedTest.cs b/src/Orb.Tests/Models/SubscriptionMinifiedTest.cs index 6fa4b4ba8..4df643d88 100644 --- a/src/Orb.Tests/Models/SubscriptionMinifiedTest.cs +++ b/src/Orb.Tests/Models/SubscriptionMinifiedTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionMinified { ID = "VDGsT23osdLb84KD" }; + + SubscriptionMinified copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/SubscriptionTrialInfoTest.cs b/src/Orb.Tests/Models/SubscriptionTrialInfoTest.cs index 0de7216af..86a50c5bd 100644 --- a/src/Orb.Tests/Models/SubscriptionTrialInfoTest.cs +++ b/src/Orb.Tests/Models/SubscriptionTrialInfoTest.cs @@ -67,4 +67,17 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionTrialInfo + { + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + SubscriptionTrialInfo copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/DiscountOverrideTest.cs b/src/Orb.Tests/Models/Subscriptions/DiscountOverrideTest.cs index 11834810a..b3e227581 100644 --- a/src/Orb.Tests/Models/Subscriptions/DiscountOverrideTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/DiscountOverrideTest.cs @@ -147,6 +147,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DiscountOverride + { + DiscountType = DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }; + + DiscountOverride copied = new(model); + + Assert.Equal(model, copied); + } } public class DiscountTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkPriceTest.cs index 0f3820aec..ba7324290 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkPriceTest.cs @@ -470,6 +470,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionBulkPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkWithProrationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkWithProrationPriceTest.cs index 83fecc6c5..b79405029 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkWithProrationPriceTest.cs @@ -538,6 +538,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionBulkWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationConfigTest : TestBase @@ -634,6 +687,23 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + Subscriptions::BulkWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationConfigTierTest : TestBase @@ -750,6 +820,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::BulkWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionBulkWithProrationPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPriceTest.cs index a9f457a04..033aa7125 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPriceTest.cs @@ -608,6 +608,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionCumulativeGroupedBulkPriceCadenceTest : TestBase @@ -804,6 +864,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + Subscriptions::CumulativeGroupedBulkConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class DimensionValueTest : TestBase @@ -884,6 +966,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::DimensionValue copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionCumulativeGroupedBulkPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedAllocationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedAllocationPriceTest.cs index 85559560d..c69292ebd 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedAllocationPriceTest.cs @@ -538,6 +538,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionGroupedAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedAllocationPriceCadenceTest : TestBase @@ -686,6 +739,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + Subscriptions::GroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedAllocationPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePriceTest.cs index 5a1b056e5..d997046eb 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePriceTest.cs @@ -578,6 +578,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionGroupedTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedTieredPackagePriceCadenceTest : TestBase @@ -758,6 +815,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + Subscriptions::GroupedTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageConfigTierTest : TestBase @@ -832,6 +908,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::GroupedTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedTieredPackagePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPriceTest.cs index b1a694a8e..27a5ba4db 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPriceTest.cs @@ -556,6 +556,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionGroupedTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedTieredPriceCadenceTest : TestBase @@ -724,6 +779,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + Subscriptions::GroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredConfigTierTest : TestBase @@ -796,6 +869,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::GroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedTieredPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPriceTest.cs index 8a51f3c86..5cf84eb59 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPriceTest.cs @@ -638,6 +638,68 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedWithMeteredMinimumPriceCadenceTest : TestBase @@ -864,6 +926,30 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + Subscriptions::GroupedWithMeteredMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalingFactorTest : TestBase @@ -936,6 +1022,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + Subscriptions::ScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitAmountTest : TestBase @@ -1008,6 +1108,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + Subscriptions::UnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedWithMeteredMinimumPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPriceTest.cs index 68abda60d..3e9a4a2f9 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPriceTest.cs @@ -548,6 +548,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedWithProratedMinimumPriceCadenceTest : TestBase @@ -702,6 +755,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + Subscriptions::GroupedWithProratedMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedWithProratedMinimumPriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixPriceTest.cs index aaf9ee512..0cc0c8c3a 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixPriceTest.cs @@ -518,6 +518,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewSubscriptionMatrixPrice + { + Cadence = NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = 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", + }; + + NewSubscriptionMatrixPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMatrixPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPriceTest.cs index 6182d23fc..9e03261cb 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPriceTest.cs @@ -528,6 +528,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewSubscriptionMatrixWithAllocationPrice + { + Cadence = NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = 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", + }; + + NewSubscriptionMatrixWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMatrixWithAllocationPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePriceTest.cs index 7be943228..d92366fec 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePriceTest.cs @@ -608,6 +608,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMatrixWithDisplayNamePriceCadenceTest : TestBase @@ -804,6 +864,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + Subscriptions::MatrixWithDisplayNameConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameConfigUnitAmountTest : TestBase @@ -886,6 +968,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + Subscriptions::MatrixWithDisplayNameConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMatrixWithDisplayNamePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePriceTest.cs index 50c552149..77f355429 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePriceTest.cs @@ -578,6 +578,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMaxGroupTieredPackagePriceCadenceTest : TestBase @@ -758,6 +815,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + Subscriptions::MaxGroupTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackageConfigTierTest : TestBase @@ -832,6 +908,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::MaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::MaxGroupTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMaxGroupTieredPackagePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMinimumCompositePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMinimumCompositePriceTest.cs index d3a16fa79..a3ef343c3 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMinimumCompositePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMinimumCompositePriceTest.cs @@ -496,6 +496,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionMinimumCompositePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMinimumCompositePriceCadenceTest : TestBase @@ -682,6 +730,20 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + Subscriptions::MinimumCompositeConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMinimumCompositePriceModelTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackagePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackagePriceTest.cs index e99562009..189fcaf5f 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackagePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackagePriceTest.cs @@ -476,6 +476,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewSubscriptionPackagePrice + { + Cadence = NewSubscriptionPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = 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", + }; + + NewSubscriptionPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionPackagePriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackageWithAllocationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackageWithAllocationPriceTest.cs index 2a0fb62a9..40986b2b6 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackageWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackageWithAllocationPriceTest.cs @@ -538,6 +538,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionPackageWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionPackageWithAllocationPriceCadenceTest : TestBase @@ -748,6 +801,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + Subscriptions::PackageWithAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionPackageWithAllocationPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.cs index 5e90107dd..501c78839 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.cs @@ -686,6 +686,73 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionScalableMatrixWithTieredPricingPriceCadenceTest : TestBase @@ -1140,6 +1207,34 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + Subscriptions::ScalableMatrixWithTieredPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixScalingFactorTest : TestBase @@ -1274,6 +1369,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + Subscriptions::MatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingConfigTierTest : TestBase @@ -1348,6 +1458,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::ScalableMatrixWithTieredPricingConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionScalableMatrixWithTieredPricingPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs index fca49bafa..2beb8456a 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs @@ -656,6 +656,70 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionScalableMatrixWithUnitPricingPriceCadenceTest : TestBase @@ -1056,6 +1120,31 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }; + + Subscriptions::ScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest : TestBase @@ -1192,6 +1281,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + Subscriptions::ScalableMatrixWithUnitPricingConfigMatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionScalableMatrixWithUnitPricingPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPriceTest.cs index 0ac5be6c6..e70c2bf9f 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPriceTest.cs @@ -568,6 +568,62 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionThresholdTotalAmountPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionThresholdTotalAmountPriceCadenceTest : TestBase @@ -868,6 +924,24 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + Subscriptions::ThresholdTotalAmountConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ConsumptionTableTest : TestBase @@ -940,6 +1014,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + Subscriptions::ConsumptionTable copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionThresholdTotalAmountPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackagePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackagePriceTest.cs index 74f87eaf5..ca23c4010 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackagePriceTest.cs @@ -556,6 +556,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredPackagePriceCadenceTest : TestBase @@ -778,6 +833,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + Subscriptions::TieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageConfigTierTest : TestBase @@ -850,6 +923,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::TieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredPackagePriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPriceTest.cs index deb5172f7..d2805d237 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPriceTest.cs @@ -673,6 +673,72 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredPackageWithMinimumPriceCadenceTest : TestBase @@ -973,6 +1039,34 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + Subscriptions::TieredPackageWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageWithMinimumConfigTierTest : TestBase @@ -1055,6 +1149,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::TieredPackageWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredPackageWithMinimumPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPriceTest.cs index fe14d4d5a..82bc82207 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPriceTest.cs @@ -588,6 +588,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewSubscriptionTieredPrice + { + Cadence = NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = 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", + }; + + NewSubscriptionTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredWithMinimumPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredWithMinimumPriceTest.cs index 5a4ac5561..07b469b0e 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredWithMinimumPriceTest.cs @@ -678,6 +678,73 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionTieredWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredWithMinimumPriceCadenceTest : TestBase @@ -1090,6 +1157,35 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredWithMinimumConfig + { + 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, + }; + + Subscriptions::TieredWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithMinimumConfigTierTest : TestBase @@ -1170,6 +1266,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::TieredWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredWithMinimumPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitPriceTest.cs index f7d53ffe7..5f668bcc9 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitPriceTest.cs @@ -468,6 +468,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewSubscriptionUnitPrice + { + Cadence = NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = 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", + }; + + NewSubscriptionUnitPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionUnitPriceCadenceTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithPercentPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithPercentPriceTest.cs index 9c537797b..f59f8fb0b 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithPercentPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithPercentPriceTest.cs @@ -484,6 +484,53 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionUnitWithPercentPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionUnitWithPercentPriceCadenceTest : TestBase @@ -678,6 +725,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::UnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + Subscriptions::UnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionUnitWithPercentPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithProrationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithProrationPriceTest.cs index 357734376..a69e6c049 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithProrationPriceTest.cs @@ -488,6 +488,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::NewSubscriptionUnitWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionUnitWithProrationPriceCadenceTest : TestBase @@ -666,6 +714,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + Subscriptions::UnitWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionUnitWithProrationPriceConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs index d7fb74b59..621241f56 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs @@ -1989,6 +1989,41 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + 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::AddAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class AdjustmentTest : TestBase @@ -2932,6 +2967,96 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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"), + }; + + Subscriptions::AddPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceTest : TestBase @@ -6868,6 +6993,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigTest : TestBase @@ -6986,6 +7165,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + 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" }, + ], + }; + + Subscriptions::BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -7042,6 +7239,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; + + Subscriptions::Filter copied = new(model); + + Assert.Equal(model, copied); + } } public class TierTest : TestBase @@ -7158,6 +7365,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Tier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::Tier copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -7774,6 +7995,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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 = "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", + }; + + Subscriptions::TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationCadenceTest : TestBase @@ -7914,7 +8183,20 @@ public void Validation_Works() model.Validate(); } -} + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + Subscriptions::TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} public class TieredWithProrationConfigTierTest : TestBase { @@ -7986,6 +8268,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationConversionRateConfigTest : TestBase @@ -8594,6 +8890,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedWithMinMaxThresholds + { + 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", + }; + + Subscriptions::GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -8748,6 +9096,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + Subscriptions::GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -9356,6 +9720,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::CumulativeGroupedAllocation + { + 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", + }; + + Subscriptions::CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -9510,6 +9926,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -10046,6 +10478,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + 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", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::Percent copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentCadenceTest : TestBase @@ -10162,6 +10640,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PercentConfig { Percent = 0 }; + + Subscriptions::PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentConversionRateConfigTest : TestBase @@ -10742,6 +11230,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + 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", + BillableMetricID = "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", + }; + + Subscriptions::EventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputCadenceTest : TestBase @@ -10936,10 +11475,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } -} -public class EventOutputConversionRateConfigTest : TestBase -{ + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + Subscriptions::EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EventOutputConversionRateConfigTest : TestBase +{ [Fact] public void UnitValidationWorks() { @@ -11127,6 +11681,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + Subscriptions::RemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class RemovePriceTest : TestBase @@ -11237,6 +11801,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + Subscriptions::RemovePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplaceAdjustmentTest : TestBase @@ -11423,6 +12001,39 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplaceAdjustment + { + 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::ReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplaceAdjustmentAdjustmentTest : TestBase @@ -12352,6 +12963,95 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePrice + { + 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", + }; + + Subscriptions::ReplacePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTest : TestBase @@ -16348,6 +17048,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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 = "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", + }; + + Subscriptions::ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase @@ -16468,6 +17222,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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" }, + ], + }; + + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase @@ -16542,6 +17314,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase @@ -16666,6 +17454,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase @@ -17290,15 +18094,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } -} -public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [Fact] + public void CopyConstructor_Works() + { + 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" }] + ), + BillableMetricID = "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", + }; + + Subscriptions::ReplacePricePriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceTieredWithProrationCadenceTest : 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( @@ -17438,6 +18290,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase @@ -17516,6 +18383,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase @@ -18132,6 +19015,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -18295,6 +19230,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -18911,6 +19864,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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", + }; + + Subscriptions::ReplacePricePriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase @@ -19074,6 +20079,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -19610,6 +20633,52 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = 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"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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", + }; + + Subscriptions::ReplacePricePricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentCadenceTest : TestBase @@ -19728,6 +20797,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePricePricePercentPercentConfig { Percent = 0 }; + + Subscriptions::ReplacePricePricePercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentConversionRateConfigTest : TestBase @@ -20316,6 +21395,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePricePriceEventOutput + { + 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", + }; + + Subscriptions::ReplacePricePriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputCadenceTest : TestBase @@ -20518,6 +21648,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + Subscriptions::ReplacePricePriceEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputConversionRateConfigTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs index 7e5ba5e46..49d4910c1 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs @@ -875,4 +875,150 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionFetchCostsResponse + { + Data = + [ + new() + { + PerPriceCosts = + [ + new() + { + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + PriceID = "price_id", + Subtotal = "subtotal", + Total = "total", + Quantity = 0, + }, + ], + Subtotal = "subtotal", + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "total", + }, + ], + }; + + SubscriptionFetchCostsResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchSchedulePageResponseTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchSchedulePageResponseTest.cs index 55a5139af..dd4cb3925 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchSchedulePageResponseTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchSchedulePageResponseTest.cs @@ -177,4 +177,32 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionFetchSchedulePageResponse + { + Data = + [ + new() + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Plan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + SubscriptionFetchSchedulePageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleResponseTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleResponseTest.cs index 5d37eb9a7..16f6fbe08 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleResponseTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleResponseTest.cs @@ -121,6 +121,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionFetchScheduleResponse + { + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Plan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + SubscriptionFetchScheduleResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class PlanTest : TestBase @@ -195,4 +216,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Plan + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }; + + Plan copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs index d66ad3bdd..4a23ba521 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs @@ -1591,6 +1591,96 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Add + { + 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"], + }; + + Subscriptions::Add copied = new(model); + + Assert.Equal(model, copied); + } } public class StartDateTest : TestBase @@ -1753,6 +1843,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Amount { AmountDiscount = 0 }; + + Subscriptions::Amount copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentageTest : TestBase @@ -1809,6 +1909,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Percentage { PercentageDiscount = 0.15 }; + + Subscriptions::Percentage copied = new(model); + + Assert.Equal(model, copied); + } } public class UsageTest : TestBase @@ -1865,6 +1975,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Usage { UsageDiscount = 2 }; + + Subscriptions::Usage copied = new(model); + + Assert.Equal(model, copied); + } } public class EndDateTest : TestBase @@ -1980,6 +2100,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::FixedFeeQuantityTransition + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Quantity = 5, + }; + + Subscriptions::FixedFeeQuantityTransition copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelTest : TestBase @@ -5792,6 +5926,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelBulkWithFilters + { + 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::PriceModelBulkWithFiltersCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + Subscriptions::PriceModelBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelBulkWithFiltersBulkWithFiltersConfigTest : TestBase @@ -5912,6 +6099,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + Subscriptions::PriceModelBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase @@ -5986,6 +6191,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + Subscriptions::PriceModelBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase @@ -6110,6 +6329,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::PriceModelBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelBulkWithFiltersCadenceTest : TestBase @@ -6772,48 +7005,99 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } -} - -public class PriceModelGroupedWithMinMaxThresholdsCadenceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works( - Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence 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::PriceModelGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works( - Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence rawValue - ) + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + { + Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + Subscriptions::PriceModelGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceModelGroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works( + Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence 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::PriceModelGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence rawValue + ) { // force implicit conversion because Theory can't do that for us ApiEnum value = @@ -6934,6 +7218,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceModelGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -7532,6 +7834,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + { + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + Subscriptions::PriceModelCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelCumulativeGroupedAllocationCadenceTest : TestBase @@ -7694,6 +8047,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceModelCumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -8214,6 +8585,51 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelPercent + { + Cadence = Subscriptions::PriceModelPercentCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + Subscriptions::PriceModelPercent copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelPercentCadenceTest : TestBase @@ -8330,6 +8746,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelPercentPercentConfig { Percent = 0 }; + + Subscriptions::PriceModelPercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelPercentConversionRateConfigTest : TestBase @@ -8900,6 +9326,56 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelEventOutput + { + Cadence = Subscriptions::PriceModelEventOutputCadence.Annual, + Currency = "currency", + 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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" } }, + }; + + Subscriptions::PriceModelEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelEventOutputCadenceTest : TestBase @@ -9100,6 +9576,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + Subscriptions::PriceModelEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelEventOutputConversionRateConfigTest : TestBase @@ -9455,6 +9946,41 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment + { + 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"), + }; + + Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionPriceIntervalsParamsAddAdjustmentStartDateTest : TestBase @@ -10253,6 +10779,33 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Edit + { + 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"], + }; + + Subscriptions::Edit copied = new(model); + + Assert.Equal(model, copied); + } } public class EditEndDateTest : TestBase @@ -10370,6 +10923,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::EditFixedFeeQuantityTransition + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Quantity = 5, + }; + + Subscriptions::EditFixedFeeQuantityTransition copied = new(model); + + Assert.Equal(model, copied); + } } public class EditStartDateTest : TestBase @@ -10611,6 +11178,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::EditAdjustment + { + AdjustmentIntervalID = "sdfs6wdjvn7ujokd", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Subscriptions::EditAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class EditAdjustmentEndDateTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs index 451cef5eb..8eec26e8e 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs @@ -1462,6 +1462,41 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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::SubscriptionSchedulePlanChangeParamsAddAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentTest : TestBase @@ -2424,6 +2459,96 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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"), + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceTest : TestBase @@ -6505,6 +6630,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + 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", + BillableMetricID = "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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTest @@ -6630,6 +6812,26 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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" }, + ], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest @@ -6709,6 +6911,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest @@ -6842,6 +7060,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadenceTest : TestBase @@ -7529,46 +7763,97 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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() + public void CopyConstructor_Works() { - var value = JsonSerializer.Deserialize< + 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 = "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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration copied = + new(model); + + Assert.Equal(model, copied); + } +} + +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 @@ -7723,6 +8008,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierTest @@ -7802,6 +8102,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest @@ -8436,6 +8752,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest @@ -8640,6 +9011,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest @@ -9274,6 +9663,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + 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 = "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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest @@ -9478,6 +9922,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest @@ -10031,7 +10493,54 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReferenceID = null, }; - model.Validate(); + model.Validate(); + } + + [Fact] + public void CopyConstructor_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() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent copied = new(model); + + Assert.Equal(model, copied); } } @@ -10211,6 +10720,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + { + Percent = 0, + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest @@ -10816,6 +11340,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase @@ -11071,6 +11649,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest @@ -11277,6 +11872,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + { + AdjustmentID = "h74gfhdjvn7ujokd", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase @@ -11397,6 +12005,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase @@ -11587,6 +12209,39 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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::SubscriptionSchedulePlanChangeParamsReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase @@ -12502,42 +13157,131 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() 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, - }; + 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(); + } + + [Fact] + public void CopyConstructor_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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } @@ -16620,6 +17364,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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", + BillableMetricID = "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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest @@ -16745,6 +17546,26 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_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" }, + ], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest @@ -16824,6 +17645,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest @@ -16957,6 +17794,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceTest @@ -17645,6 +18498,57 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + { + 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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceTest @@ -17839,6 +18743,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest @@ -17918,6 +18837,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigTest @@ -18518,7 +19453,43 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + { + 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 = 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 CopyConstructor_Works() { var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds @@ -18534,23 +19505,42 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, 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 = "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(); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds copied = + new(model); + + Assert.Equal(model, copied); } } @@ -18756,6 +19746,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest @@ -19390,6 +20398,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + 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 = "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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceTest @@ -19594,6 +20657,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest @@ -20149,6 +21230,55 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent + { + 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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadenceTest : TestBase @@ -20328,6 +21458,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentPercentConfig + { + Percent = 0, + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentPercentConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePricePercentConversionRateConfigTest @@ -20941,6 +22086,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput + { + 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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadenceTest : TestBase @@ -21196,6 +22395,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputEventOutputConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputConversionRateConfigTest diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs index 26c6fff7b..52a4464d0 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs @@ -3925,4 +3925,659 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new SubscriptionSubscriptions + { + Data = + [ + new() + { + ID = "id", + ActivePlanPhaseOrder = 0, + AdjustmentIntervals = + [ + new() + { + ID = "id", + Adjustment = new PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AutoCollection = true, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, + }, + BillingCycleDay = 1, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + Customer = new() + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = + [ + new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + ], + Parent = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }, + DefaultInvoiceMemo = "default_invoice_memo", + DiscountIntervals = + [ + new AmountDiscountInterval() + { + AmountDiscount = "amount_discount", + AppliesToPriceIntervalIds = ["string"], + DiscountType = AmountDiscountIntervalDiscountType.Amount, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AmountDiscountIntervalFilterField.PriceID, + Operator = AmountDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FixedFeeQuantitySchedule = + [ + new() + { + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + InvoicingThreshold = "invoicing_threshold", + MaximumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = MaximumIntervalFilterField.PriceID, + Operator = MaximumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + MinimumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = MinimumIntervalFilterField.PriceID, + Operator = MinimumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Name = "name", + NetTerms = 0, + PendingSubscriptionChange = new("id"), + Plan = new() + { + ID = "id", + Adjustments = + [ + new PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = + PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + BasePlan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + BasePlanID = "base_plan_id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPlanID = "external_plan_id", + InvoicingCurrency = "invoicing_currency", + 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", + NetTerms = 0, + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + Duration = 0, + DurationUnit = Plans::PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Product = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }, + Status = Plans::PlanStatus.Active, + TrialConfig = new() + { + TrialPeriod = 0, + TrialPeriodUnit = Plans::TrialPeriodUnit.Days, + }, + Version = 0, + }, + PriceIntervals = + [ + new() + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }, + ], + RedeemedCoupon = new() + { + CouponID = "coupon_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = SubscriptionStatus.Active, + TrialInfo = new(DateTimeOffset.Parse("2019-12-27T18:11:19.117Z")), + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + SubscriptionSubscriptions copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs index 5bcce082a..896a52e93 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs @@ -3911,6 +3911,639 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscription + { + ID = "id", + ActivePlanPhaseOrder = 0, + AdjustmentIntervals = + [ + new() + { + ID = "id", + Adjustment = new PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AutoCollection = true, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, + }, + BillingCycleDay = 1, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Customer = new() + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = [new() { ID = "id", ExternalCustomerID = "external_customer_id" }], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }, + DefaultInvoiceMemo = "default_invoice_memo", + DiscountIntervals = + [ + new AmountDiscountInterval() + { + AmountDiscount = "amount_discount", + AppliesToPriceIntervalIds = ["string"], + DiscountType = AmountDiscountIntervalDiscountType.Amount, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = AmountDiscountIntervalFilterField.PriceID, + Operator = AmountDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + FixedFeeQuantitySchedule = + [ + new() + { + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + InvoicingThreshold = "invoicing_threshold", + MaximumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = MaximumIntervalFilterField.PriceID, + Operator = MaximumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + MinimumIntervals = + [ + new() + { + AppliesToPriceIntervalIds = ["string"], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = MinimumIntervalFilterField.PriceID, + Operator = MinimumIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + Name = "name", + NetTerms = 0, + PendingSubscriptionChange = new("id"), + Plan = new() + { + ID = "id", + Adjustments = + [ + new PlanPhaseUsageDiscountAdjustment() + { + ID = "id", + AdjustmentType = + PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount, + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID, + Operator = PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PlanPhaseOrder = 0, + Reason = "reason", + ReplacesAdjustmentID = "replaces_adjustment_id", + UsageDiscount = 0, + }, + ], + BasePlan = new() + { + ID = "m2t5akQeh2obwxeU", + ExternalPlanID = "m2t5akQeh2obwxeU", + Name = "Example plan", + }, + BasePlanID = "base_plan_id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPlanID = "external_plan_id", + InvoicingCurrency = "invoicing_currency", + 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", + NetTerms = 0, + PlanPhases = + [ + new() + { + ID = "id", + Description = "description", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + Duration = 0, + DurationUnit = Plans::PlanPlanPhaseDurationUnit.Daily, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + Order = 0, + }, + ], + Prices = + [ + new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + ], + Product = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Name = "name", + }, + Status = Plans::PlanStatus.Active, + TrialConfig = new() + { + TrialPeriod = 0, + TrialPeriodUnit = Plans::TrialPeriodUnit.Days, + }, + Version = 0, + }, + PriceIntervals = + [ + new() + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }, + ], + RedeemedCoupon = new() + { + CouponID = "coupon_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = SubscriptionStatus.Active, + TrialInfo = new(DateTimeOffset.Parse("2019-12-27T18:11:19.117Z")), + }; + + Subscription copied = new(model); + + Assert.Equal(model, copied); + } } public class DiscountIntervalTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionUsageTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionUsageTest.cs index e8f2d90b5..93bd33bca 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUsageTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUsageTest.cs @@ -301,6 +301,35 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UngroupedSubscriptionUsage + { + Data = + [ + new() + { + BillableMetric = new() { ID = "id", Name = "name" }, + Usage = + [ + new() + { + Quantity = 0, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + ViewMode = DataViewMode.Periodic, + }, + ], + }; + + UngroupedSubscriptionUsage copied = new(model); + + Assert.Equal(model, copied); + } } public class DataTest : TestBase @@ -431,6 +460,29 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Data + { + BillableMetric = new() { ID = "id", Name = "name" }, + Usage = + [ + new() + { + Quantity = 0, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + ViewMode = DataViewMode.Periodic, + }; + + Data copied = new(model); + + Assert.Equal(model, copied); + } } public class BillableMetricTest : TestBase @@ -487,6 +539,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BillableMetric { ID = "id", Name = "name" }; + + BillableMetric copied = new(model); + + Assert.Equal(model, copied); + } } public class DataUsageTest : TestBase @@ -564,6 +626,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DataUsage + { + Quantity = 0, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + DataUsage copied = new(model); + + Assert.Equal(model, copied); + } } public class DataViewModeTest : TestBase @@ -970,6 +1047,41 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedSubscriptionUsage + { + Data = + [ + new() + { + BillableMetric = new() { ID = "id", Name = "name" }, + MetricGroup = new() + { + PropertyKey = "property_key", + PropertyValue = "property_value", + }, + Usage = + [ + new() + { + Quantity = 0, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + ViewMode = GroupedSubscriptionUsageDataViewMode.Periodic, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + GroupedSubscriptionUsage copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedSubscriptionUsageDataTest : TestBase @@ -1132,6 +1244,30 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedSubscriptionUsageData + { + BillableMetric = new() { ID = "id", Name = "name" }, + MetricGroup = new() { PropertyKey = "property_key", PropertyValue = "property_value" }, + Usage = + [ + new() + { + Quantity = 0, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + ViewMode = GroupedSubscriptionUsageDataViewMode.Periodic, + }; + + GroupedSubscriptionUsageData copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedSubscriptionUsageDataBillableMetricTest : TestBase @@ -1188,6 +1324,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedSubscriptionUsageDataBillableMetric { ID = "id", Name = "name" }; + + GroupedSubscriptionUsageDataBillableMetric copied = new(model); + + Assert.Equal(model, copied); + } } public class MetricGroupTest : TestBase @@ -1260,6 +1406,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MetricGroup + { + PropertyKey = "property_key", + PropertyValue = "property_value", + }; + + MetricGroup copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedSubscriptionUsageDataUsageTest : TestBase @@ -1340,6 +1500,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedSubscriptionUsageDataUsage + { + Quantity = 0, + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + GroupedSubscriptionUsageDataUsage copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedSubscriptionUsageDataViewModeTest : TestBase diff --git a/src/Orb.Tests/Models/TaxAmountTest.cs b/src/Orb.Tests/Models/TaxAmountTest.cs index 1d65b0daf..5dee77144 100644 --- a/src/Orb.Tests/Models/TaxAmountTest.cs +++ b/src/Orb.Tests/Models/TaxAmountTest.cs @@ -79,4 +79,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TaxAmount + { + Amount = "amount", + TaxRateDescription = "tax_rate_description", + TaxRatePercentage = "tax_rate_percentage", + }; + + TaxAmount copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/TierSubLineItemTest.cs b/src/Orb.Tests/Models/TierSubLineItemTest.cs index 76f802d93..1a8c4266d 100644 --- a/src/Orb.Tests/Models/TierSubLineItemTest.cs +++ b/src/Orb.Tests/Models/TierSubLineItemTest.cs @@ -137,6 +137,29 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TierSubLineItem + { + Amount = "9.00", + Grouping = new() { Key = "region", Value = "west" }, + Name = "Tier One", + Quantity = 5, + TierConfig = new() + { + FirstUnit = 1, + LastUnit = 1000, + UnitAmount = "3.00", + }, + Type = TierSubLineItemType.Tier, + }; + + TierSubLineItem copied = new(model); + + Assert.Equal(model, copied); + } } public class TierConfigTest : TestBase @@ -217,6 +240,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TierConfig + { + FirstUnit = 1, + LastUnit = 1000, + UnitAmount = "3.00", + }; + + TierConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TierSubLineItemTypeTest : TestBase diff --git a/src/Orb.Tests/Models/TieredConfigTest.cs b/src/Orb.Tests/Models/TieredConfigTest.cs index 9ddb27628..76a3ea5e4 100644 --- a/src/Orb.Tests/Models/TieredConfigTest.cs +++ b/src/Orb.Tests/Models/TieredConfigTest.cs @@ -215,4 +215,26 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredConfig + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; + + TieredConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/TopLevel/TopLevelPingResponseTest.cs b/src/Orb.Tests/Models/TopLevel/TopLevelPingResponseTest.cs index 18b444d93..b60482e39 100644 --- a/src/Orb.Tests/Models/TopLevel/TopLevelPingResponseTest.cs +++ b/src/Orb.Tests/Models/TopLevel/TopLevelPingResponseTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopLevelPingResponse { Response = "response" }; + + TopLevelPingResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/TrialDiscountTest.cs b/src/Orb.Tests/Models/TrialDiscountTest.cs index 257c98774..33c59b7a4 100644 --- a/src/Orb.Tests/Models/TrialDiscountTest.cs +++ b/src/Orb.Tests/Models/TrialDiscountTest.cs @@ -246,6 +246,32 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TrialDiscount + { + DiscountType = TrialDiscountDiscountType.Trial, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = TrialDiscountFilterField.PriceID, + Operator = TrialDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + TrialAmountDiscount = "trial_amount_discount", + TrialPercentageDiscount = 0, + }; + + TrialDiscount copied = new(model); + + Assert.Equal(model, copied); + } } public class TrialDiscountDiscountTypeTest : TestBase @@ -392,6 +418,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TrialDiscountFilter + { + Field = TrialDiscountFilterField.PriceID, + Operator = TrialDiscountFilterOperator.Includes, + Values = ["string"], + }; + + TrialDiscountFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class TrialDiscountFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/UnitConfigTest.cs b/src/Orb.Tests/Models/UnitConfigTest.cs index 92b6e9951..239ef80c6 100644 --- a/src/Orb.Tests/Models/UnitConfigTest.cs +++ b/src/Orb.Tests/Models/UnitConfigTest.cs @@ -104,4 +104,14 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitConfig { UnitAmount = "unit_amount", Prorated = true }; + + UnitConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/UsageDiscountIntervalTest.cs b/src/Orb.Tests/Models/UsageDiscountIntervalTest.cs index 8ea3c74fd..e579f356d 100644 --- a/src/Orb.Tests/Models/UsageDiscountIntervalTest.cs +++ b/src/Orb.Tests/Models/UsageDiscountIntervalTest.cs @@ -184,6 +184,32 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageDiscountInterval + { + AppliesToPriceIntervalIds = ["string"], + DiscountType = UsageDiscountIntervalDiscountType.Usage, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = UsageDiscountIntervalFilterField.PriceID, + Operator = UsageDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageDiscount = 0, + }; + + UsageDiscountInterval copied = new(model); + + Assert.Equal(model, copied); + } } public class UsageDiscountIntervalDiscountTypeTest : TestBase @@ -330,6 +356,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageDiscountIntervalFilter + { + Field = UsageDiscountIntervalFilterField.PriceID, + Operator = UsageDiscountIntervalFilterOperator.Includes, + Values = ["string"], + }; + + UsageDiscountIntervalFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class UsageDiscountIntervalFilterFieldTest : TestBase diff --git a/src/Orb.Tests/Models/UsageDiscountTest.cs b/src/Orb.Tests/Models/UsageDiscountTest.cs index a2cc8770b..7c6ee8a5a 100644 --- a/src/Orb.Tests/Models/UsageDiscountTest.cs +++ b/src/Orb.Tests/Models/UsageDiscountTest.cs @@ -236,6 +236,31 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageDiscount + { + DiscountType = UsageDiscountDiscountType.Usage, + UsageDiscountValue = 0, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = UsageDiscountFilterField.PriceID, + Operator = UsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }; + + UsageDiscount copied = new(model); + + Assert.Equal(model, copied); + } } public class UsageDiscountDiscountTypeTest : TestBase @@ -382,6 +407,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageDiscountFilter + { + Field = UsageDiscountFilterField.PriceID, + Operator = UsageDiscountFilterOperator.Includes, + Values = ["string"], + }; + + UsageDiscountFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class UsageDiscountFilterFieldTest : TestBase diff --git a/src/Orb/Models/Address.cs b/src/Orb/Models/Address.cs index ebf92125c..ccd1963a6 100644 --- a/src/Orb/Models/Address.cs +++ b/src/Orb/Models/Address.cs @@ -83,8 +83,11 @@ public override void Validate() public Address() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Address(Address address) : base(address) { } +#pragma warning restore CS8618 public Address(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/AdjustmentInterval.cs b/src/Orb/Models/AdjustmentInterval.cs index 26f9bd154..b667c2d9b 100644 --- a/src/Orb/Models/AdjustmentInterval.cs +++ b/src/Orb/Models/AdjustmentInterval.cs @@ -92,8 +92,11 @@ public override void Validate() public AdjustmentInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AdjustmentInterval(AdjustmentInterval adjustmentInterval) : base(adjustmentInterval) { } +#pragma warning restore CS8618 public AdjustmentInterval(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/AggregatedCost.cs b/src/Orb/Models/AggregatedCost.cs index a227a731d..f8d8432ec 100644 --- a/src/Orb/Models/AggregatedCost.cs +++ b/src/Orb/Models/AggregatedCost.cs @@ -89,8 +89,11 @@ public override void Validate() public AggregatedCost() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AggregatedCost(AggregatedCost aggregatedCost) : base(aggregatedCost) { } +#pragma warning restore CS8618 public AggregatedCost(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Alerts/Alert.cs b/src/Orb/Models/Alerts/Alert.cs index 97be8edfd..61b2fefd2 100644 --- a/src/Orb/Models/Alerts/Alert.cs +++ b/src/Orb/Models/Alerts/Alert.cs @@ -200,8 +200,11 @@ public override void Validate() public Alert() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Alert(Alert alert) : base(alert) { } +#pragma warning restore CS8618 public Alert(IReadOnlyDictionary rawData) { @@ -254,8 +257,11 @@ public override void Validate() public Metric() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Metric(Metric metric) : base(metric) { } +#pragma warning restore CS8618 public Metric(IReadOnlyDictionary rawData) { @@ -353,8 +359,11 @@ public override void Validate() public Plan() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Plan(Plan plan) : base(plan) { } +#pragma warning restore CS8618 public Plan(IReadOnlyDictionary rawData) { @@ -480,8 +489,11 @@ public override void Validate() public BalanceAlertStatus() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceAlertStatus(BalanceAlertStatus balanceAlertStatus) : base(balanceAlertStatus) { } +#pragma warning restore CS8618 public BalanceAlertStatus(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Alerts/AlertListPageResponse.cs b/src/Orb/Models/Alerts/AlertListPageResponse.cs index 2bd78847a..481fd4796 100644 --- a/src/Orb/Models/Alerts/AlertListPageResponse.cs +++ b/src/Orb/Models/Alerts/AlertListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public AlertListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertListPageResponse(AlertListPageResponse alertListPageResponse) : base(alertListPageResponse) { } +#pragma warning restore CS8618 public AlertListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Alerts/Threshold.cs b/src/Orb/Models/Alerts/Threshold.cs index 1d05524bd..1e9414f1e 100644 --- a/src/Orb/Models/Alerts/Threshold.cs +++ b/src/Orb/Models/Alerts/Threshold.cs @@ -36,8 +36,11 @@ public override void Validate() public Threshold() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Threshold(Threshold threshold) : base(threshold) { } +#pragma warning restore CS8618 public Threshold(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Allocation.cs b/src/Orb/Models/Allocation.cs index df5f2f15d..c00a30546 100644 --- a/src/Orb/Models/Allocation.cs +++ b/src/Orb/Models/Allocation.cs @@ -78,8 +78,11 @@ public override void Validate() public Allocation() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Allocation(Allocation allocation) : base(allocation) { } +#pragma warning restore CS8618 public Allocation(IReadOnlyDictionary rawData) { @@ -166,8 +169,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/AmountDiscount.cs b/src/Orb/Models/AmountDiscount.cs index 367cd3fde..ad94e97d3 100644 --- a/src/Orb/Models/AmountDiscount.cs +++ b/src/Orb/Models/AmountDiscount.cs @@ -100,8 +100,11 @@ public override void Validate() public AmountDiscount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AmountDiscount(AmountDiscount amountDiscount) : base(amountDiscount) { } +#pragma warning restore CS8618 public AmountDiscount(IReadOnlyDictionary rawData) { @@ -233,8 +236,11 @@ public override void Validate() public AmountDiscountFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AmountDiscountFilter(AmountDiscountFilter amountDiscountFilter) : base(amountDiscountFilter) { } +#pragma warning restore CS8618 public AmountDiscountFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/AmountDiscountInterval.cs b/src/Orb/Models/AmountDiscountInterval.cs index 5ddc6828f..f7f12f19a 100644 --- a/src/Orb/Models/AmountDiscountInterval.cs +++ b/src/Orb/Models/AmountDiscountInterval.cs @@ -122,8 +122,11 @@ public override void Validate() public AmountDiscountInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AmountDiscountInterval(AmountDiscountInterval amountDiscountInterval) : base(amountDiscountInterval) { } +#pragma warning restore CS8618 public AmountDiscountInterval(IReadOnlyDictionary rawData) { @@ -261,8 +264,11 @@ public override void Validate() public AmountDiscountIntervalFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AmountDiscountIntervalFilter(AmountDiscountIntervalFilter amountDiscountIntervalFilter) : base(amountDiscountIntervalFilter) { } +#pragma warning restore CS8618 public AmountDiscountIntervalFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs index 8f63e6672..11b89c315 100644 --- a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs @@ -328,8 +328,11 @@ public override void Validate() public AddAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddAdjustment(AddAdjustment addAdjustment) : base(addAdjustment) { } +#pragma warning restore CS8618 public AddAdjustment(IReadOnlyDictionary rawData) { @@ -893,8 +896,11 @@ public override void Validate() public AddPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddPrice(AddPrice addPrice) : base(addPrice) { } +#pragma warning restore CS8618 public AddPrice(IReadOnlyDictionary rawData) { @@ -3809,8 +3815,11 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } +#pragma warning restore CS8618 public BulkWithFilters(IReadOnlyDictionary rawData) { @@ -3900,8 +3909,11 @@ public override void Validate() public BulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { @@ -3974,8 +3986,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -4045,8 +4060,11 @@ public override void Validate() public Tier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Tier(Tier tier) : base(tier) { } +#pragma warning restore CS8618 public Tier(IReadOnlyDictionary rawData) { @@ -4711,8 +4729,11 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } +#pragma warning restore CS8618 public TieredWithProration(IReadOnlyDictionary rawData) { @@ -4845,8 +4866,11 @@ public override void Validate() public TieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationConfig(IReadOnlyDictionary rawData) { @@ -4928,10 +4952,13 @@ public override void Validate() public TieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfigTier( TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { @@ -5548,8 +5575,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -5717,10 +5747,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -6337,8 +6370,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -6506,10 +6542,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -7115,8 +7154,11 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percent(Percent percent) : base(percent) { } +#pragma warning restore CS8618 public Percent(IReadOnlyDictionary rawData) { @@ -7233,8 +7275,11 @@ public override void Validate() public PercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } +#pragma warning restore CS8618 public PercentConfig(IReadOnlyDictionary rawData) { @@ -7848,8 +7893,11 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutput(EventOutput eventOutput) : base(eventOutput) { } +#pragma warning restore CS8618 public EventOutput(IReadOnlyDictionary rawData) { @@ -7997,8 +8045,11 @@ public override void Validate() public EventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } +#pragma warning restore CS8618 public EventOutputConfig(IReadOnlyDictionary rawData) { @@ -8359,8 +8410,11 @@ public override void Validate() public RemoveAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public RemoveAdjustment(RemoveAdjustment removeAdjustment) : base(removeAdjustment) { } +#pragma warning restore CS8618 public RemoveAdjustment(IReadOnlyDictionary rawData) { @@ -8436,8 +8490,11 @@ public override void Validate() public RemovePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public RemovePrice(RemovePrice removePrice) : base(removePrice) { } +#pragma warning restore CS8618 public RemovePrice(IReadOnlyDictionary rawData) { @@ -8525,8 +8582,11 @@ public override void Validate() public ReplaceAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) : base(replaceAdjustment) { } +#pragma warning restore CS8618 public ReplaceAdjustment(IReadOnlyDictionary rawData) { @@ -9108,8 +9168,11 @@ public override void Validate() public ReplacePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePrice(ReplacePrice replacePrice) : base(replacePrice) { } +#pragma warning restore CS8618 public ReplacePrice(IReadOnlyDictionary rawData) { @@ -12120,10 +12183,13 @@ public ReplacePricePriceBulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFilters( ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { @@ -12223,10 +12289,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData @@ -12309,10 +12378,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData @@ -12395,10 +12467,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData @@ -13090,10 +13165,13 @@ public ReplacePricePriceTieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProration( ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { @@ -13231,10 +13309,13 @@ public override void Validate() public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig ) : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData @@ -13327,10 +13408,13 @@ public override void Validate() public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData @@ -13956,10 +14040,13 @@ public ReplacePricePriceGroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceGroupedWithMinMaxThresholds( ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData @@ -14131,10 +14218,13 @@ public override void Validate() public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -14766,10 +14856,13 @@ public ReplacePricePriceCumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceCumulativeGroupedAllocation( ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public ReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData @@ -14941,10 +15034,13 @@ public override void Validate() public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -15568,8 +15664,11 @@ public ReplacePricePricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePricePercent(ReplacePricePricePercent replacePricePricePercent) : base(replacePricePricePercent) { } +#pragma warning restore CS8618 public ReplacePricePricePercent(IReadOnlyDictionary rawData) { @@ -15695,10 +15794,13 @@ public override void Validate() public ReplacePricePricePercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePricePercentPercentConfig( ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig ) : base(replacePricePricePercentPercentConfig) { } +#pragma warning restore CS8618 public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary rawData) { @@ -16323,8 +16425,11 @@ public ReplacePricePriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceEventOutput(ReplacePricePriceEventOutput replacePricePriceEventOutput) : base(replacePricePriceEventOutput) { } +#pragma warning restore CS8618 public ReplacePricePriceEventOutput(IReadOnlyDictionary rawData) { @@ -16481,10 +16586,13 @@ public override void Validate() public ReplacePricePriceEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceEventOutputEventOutputConfig( ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig ) : base(replacePricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index e8de0a1a0..7a7a5ce5f 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -330,8 +330,11 @@ public override void Validate() public AddAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddAdjustment(AddAdjustment addAdjustment) : base(addAdjustment) { } +#pragma warning restore CS8618 public AddAdjustment(IReadOnlyDictionary rawData) { @@ -895,8 +898,11 @@ public override void Validate() public AddPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddPrice(AddPrice addPrice) : base(addPrice) { } +#pragma warning restore CS8618 public AddPrice(IReadOnlyDictionary rawData) { @@ -3811,8 +3817,11 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } +#pragma warning restore CS8618 public BulkWithFilters(IReadOnlyDictionary rawData) { @@ -3902,8 +3911,11 @@ public override void Validate() public BulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { @@ -3976,8 +3988,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -4047,8 +4062,11 @@ public override void Validate() public Tier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Tier(Tier tier) : base(tier) { } +#pragma warning restore CS8618 public Tier(IReadOnlyDictionary rawData) { @@ -4713,8 +4731,11 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } +#pragma warning restore CS8618 public TieredWithProration(IReadOnlyDictionary rawData) { @@ -4847,8 +4868,11 @@ public override void Validate() public TieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationConfig(IReadOnlyDictionary rawData) { @@ -4930,10 +4954,13 @@ public override void Validate() public TieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfigTier( TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { @@ -5550,8 +5577,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -5719,10 +5749,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -6339,8 +6372,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -6508,10 +6544,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -7117,8 +7156,11 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percent(Percent percent) : base(percent) { } +#pragma warning restore CS8618 public Percent(IReadOnlyDictionary rawData) { @@ -7235,8 +7277,11 @@ public override void Validate() public PercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } +#pragma warning restore CS8618 public PercentConfig(IReadOnlyDictionary rawData) { @@ -7850,8 +7895,11 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutput(EventOutput eventOutput) : base(eventOutput) { } +#pragma warning restore CS8618 public EventOutput(IReadOnlyDictionary rawData) { @@ -7999,8 +8047,11 @@ public override void Validate() public EventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } +#pragma warning restore CS8618 public EventOutputConfig(IReadOnlyDictionary rawData) { @@ -8361,8 +8412,11 @@ public override void Validate() public RemoveAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public RemoveAdjustment(RemoveAdjustment removeAdjustment) : base(removeAdjustment) { } +#pragma warning restore CS8618 public RemoveAdjustment(IReadOnlyDictionary rawData) { @@ -8438,8 +8492,11 @@ public override void Validate() public RemovePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public RemovePrice(RemovePrice removePrice) : base(removePrice) { } +#pragma warning restore CS8618 public RemovePrice(IReadOnlyDictionary rawData) { @@ -8527,8 +8584,11 @@ public override void Validate() public ReplaceAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) : base(replaceAdjustment) { } +#pragma warning restore CS8618 public ReplaceAdjustment(IReadOnlyDictionary rawData) { @@ -9110,8 +9170,11 @@ public override void Validate() public ReplacePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePrice(ReplacePrice replacePrice) : base(replacePrice) { } +#pragma warning restore CS8618 public ReplacePrice(IReadOnlyDictionary rawData) { @@ -12122,10 +12185,13 @@ public ReplacePricePriceBulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFilters( ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { @@ -12225,10 +12291,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData @@ -12311,10 +12380,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData @@ -12397,10 +12469,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData @@ -13092,10 +13167,13 @@ public ReplacePricePriceTieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProration( ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { @@ -13233,10 +13311,13 @@ public override void Validate() public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig ) : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData @@ -13329,10 +13410,13 @@ public override void Validate() public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData @@ -13958,10 +14042,13 @@ public ReplacePricePriceGroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceGroupedWithMinMaxThresholds( ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData @@ -14133,10 +14220,13 @@ public override void Validate() public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -14768,10 +14858,13 @@ public ReplacePricePriceCumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceCumulativeGroupedAllocation( ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public ReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData @@ -14943,10 +15036,13 @@ public override void Validate() public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -15570,8 +15666,11 @@ public ReplacePricePricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePricePercent(ReplacePricePricePercent replacePricePricePercent) : base(replacePricePricePercent) { } +#pragma warning restore CS8618 public ReplacePricePricePercent(IReadOnlyDictionary rawData) { @@ -15697,10 +15796,13 @@ public override void Validate() public ReplacePricePricePercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePricePercentPercentConfig( ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig ) : base(replacePricePricePercentPercentConfig) { } +#pragma warning restore CS8618 public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary rawData) { @@ -16325,8 +16427,11 @@ public ReplacePricePriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceEventOutput(ReplacePricePriceEventOutput replacePricePriceEventOutput) : base(replacePricePriceEventOutput) { } +#pragma warning restore CS8618 public ReplacePricePriceEventOutput(IReadOnlyDictionary rawData) { @@ -16483,10 +16588,13 @@ public override void Validate() public ReplacePricePriceEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceEventOutputEventOutputConfig( ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig ) : base(replacePricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Beta/PlanVersion.cs b/src/Orb/Models/Beta/PlanVersion.cs index 2e2dc1603..8a17a1e38 100644 --- a/src/Orb/Models/Beta/PlanVersion.cs +++ b/src/Orb/Models/Beta/PlanVersion.cs @@ -117,8 +117,11 @@ public override void Validate() public PlanVersion() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanVersion(PlanVersion planVersion) : base(planVersion) { } +#pragma warning restore CS8618 public PlanVersion(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Beta/PlanVersionPhase.cs b/src/Orb/Models/Beta/PlanVersionPhase.cs index b988baf92..1952ebc5d 100644 --- a/src/Orb/Models/Beta/PlanVersionPhase.cs +++ b/src/Orb/Models/Beta/PlanVersionPhase.cs @@ -92,8 +92,11 @@ public override void Validate() public PlanVersionPhase() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanVersionPhase(PlanVersionPhase planVersionPhase) : base(planVersionPhase) { } +#pragma warning restore CS8618 public PlanVersionPhase(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BillableMetricTiny.cs b/src/Orb/Models/BillableMetricTiny.cs index 01798a6bc..278ff150c 100644 --- a/src/Orb/Models/BillableMetricTiny.cs +++ b/src/Orb/Models/BillableMetricTiny.cs @@ -28,8 +28,11 @@ public override void Validate() public BillableMetricTiny() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillableMetricTiny(BillableMetricTiny billableMetricTiny) : base(billableMetricTiny) { } +#pragma warning restore CS8618 public BillableMetricTiny(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BillingCycleAnchorConfiguration.cs b/src/Orb/Models/BillingCycleAnchorConfiguration.cs index 14e19a556..fe6ba0edc 100644 --- a/src/Orb/Models/BillingCycleAnchorConfiguration.cs +++ b/src/Orb/Models/BillingCycleAnchorConfiguration.cs @@ -69,10 +69,13 @@ public override void Validate() public BillingCycleAnchorConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillingCycleAnchorConfiguration( BillingCycleAnchorConfiguration billingCycleAnchorConfiguration ) : base(billingCycleAnchorConfiguration) { } +#pragma warning restore CS8618 public BillingCycleAnchorConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BillingCycleConfiguration.cs b/src/Orb/Models/BillingCycleConfiguration.cs index 8cc67f072..53ba01b0e 100644 --- a/src/Orb/Models/BillingCycleConfiguration.cs +++ b/src/Orb/Models/BillingCycleConfiguration.cs @@ -43,8 +43,11 @@ public override void Validate() public BillingCycleConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillingCycleConfiguration(BillingCycleConfiguration billingCycleConfiguration) : base(billingCycleConfiguration) { } +#pragma warning restore CS8618 public BillingCycleConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BulkConfig.cs b/src/Orb/Models/BulkConfig.cs index 81f648b0e..0650bf979 100644 --- a/src/Orb/Models/BulkConfig.cs +++ b/src/Orb/Models/BulkConfig.cs @@ -44,8 +44,11 @@ public override void Validate() public BulkConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkConfig(BulkConfig bulkConfig) : base(bulkConfig) { } +#pragma warning restore CS8618 public BulkConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BulkTier.cs b/src/Orb/Models/BulkTier.cs index 9e46c5456..42a32b12a 100644 --- a/src/Orb/Models/BulkTier.cs +++ b/src/Orb/Models/BulkTier.cs @@ -48,8 +48,11 @@ public override void Validate() public BulkTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkTier(BulkTier bulkTier) : base(bulkTier) { } +#pragma warning restore CS8618 public BulkTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/ChangedSubscriptionResources.cs b/src/Orb/Models/ChangedSubscriptionResources.cs index 838014e07..351460a2d 100644 --- a/src/Orb/Models/ChangedSubscriptionResources.cs +++ b/src/Orb/Models/ChangedSubscriptionResources.cs @@ -120,8 +120,11 @@ public override void Validate() public ChangedSubscriptionResources() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ChangedSubscriptionResources(ChangedSubscriptionResources changedSubscriptionResources) : base(changedSubscriptionResources) { } +#pragma warning restore CS8618 public ChangedSubscriptionResources(IReadOnlyDictionary rawData) { @@ -893,9 +896,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: discount")] public CreatedInvoice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: discount")] public CreatedInvoice(CreatedInvoice createdInvoice) : base(createdInvoice) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: discount")] public CreatedInvoice(IReadOnlyDictionary rawData) @@ -1001,8 +1007,11 @@ public override void Validate() public AutoCollection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AutoCollection(AutoCollection autoCollection) : base(autoCollection) { } +#pragma warning restore CS8618 public AutoCollection(IReadOnlyDictionary rawData) { @@ -1125,8 +1134,11 @@ public override void Validate() public CreditNote() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNote(CreditNote creditNote) : base(creditNote) { } +#pragma warning restore CS8618 public CreditNote(IReadOnlyDictionary rawData) { @@ -1296,8 +1308,11 @@ public override void Validate() public CustomerBalanceTransaction() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerBalanceTransaction(CustomerBalanceTransaction customerBalanceTransaction) : base(customerBalanceTransaction) { } +#pragma warning restore CS8618 public CustomerBalanceTransaction(IReadOnlyDictionary rawData) { @@ -1783,8 +1798,11 @@ public override void Validate() public LineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LineItem(LineItem lineItem) : base(lineItem) { } +#pragma warning restore CS8618 public LineItem(IReadOnlyDictionary rawData) { @@ -2835,8 +2853,11 @@ public override void Validate() public PaymentAttempt() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PaymentAttempt(PaymentAttempt paymentAttempt) : base(paymentAttempt) { } +#pragma warning restore CS8618 public PaymentAttempt(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/ConversionRateTier.cs b/src/Orb/Models/ConversionRateTier.cs index 112380ab3..9ddfb5687 100644 --- a/src/Orb/Models/ConversionRateTier.cs +++ b/src/Orb/Models/ConversionRateTier.cs @@ -59,8 +59,11 @@ public override void Validate() public ConversionRateTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ConversionRateTier(ConversionRateTier conversionRateTier) : base(conversionRateTier) { } +#pragma warning restore CS8618 public ConversionRateTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/ConversionRateTieredConfig.cs b/src/Orb/Models/ConversionRateTieredConfig.cs index c3e5a33d0..78bb374bd 100644 --- a/src/Orb/Models/ConversionRateTieredConfig.cs +++ b/src/Orb/Models/ConversionRateTieredConfig.cs @@ -43,8 +43,11 @@ public override void Validate() public ConversionRateTieredConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ConversionRateTieredConfig(ConversionRateTieredConfig conversionRateTieredConfig) : base(conversionRateTieredConfig) { } +#pragma warning restore CS8618 public ConversionRateTieredConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/ConversionRateUnitConfig.cs b/src/Orb/Models/ConversionRateUnitConfig.cs index dd6ce120f..9eac0a9ba 100644 --- a/src/Orb/Models/ConversionRateUnitConfig.cs +++ b/src/Orb/Models/ConversionRateUnitConfig.cs @@ -33,8 +33,11 @@ public override void Validate() public ConversionRateUnitConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ConversionRateUnitConfig(ConversionRateUnitConfig conversionRateUnitConfig) : base(conversionRateUnitConfig) { } +#pragma warning restore CS8618 public ConversionRateUnitConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CouponRedemption.cs b/src/Orb/Models/CouponRedemption.cs index 73e7fe803..55c00b81e 100644 --- a/src/Orb/Models/CouponRedemption.cs +++ b/src/Orb/Models/CouponRedemption.cs @@ -51,8 +51,11 @@ public override void Validate() public CouponRedemption() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponRedemption(CouponRedemption couponRedemption) : base(couponRedemption) { } +#pragma warning restore CS8618 public CouponRedemption(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Coupons/Coupon.cs b/src/Orb/Models/Coupons/Coupon.cs index 2783b1732..719abb523 100644 --- a/src/Orb/Models/Coupons/Coupon.cs +++ b/src/Orb/Models/Coupons/Coupon.cs @@ -123,8 +123,11 @@ public override void Validate() public Coupon() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Coupon(Coupon coupon) : base(coupon) { } +#pragma warning restore CS8618 public Coupon(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Coupons/CouponCreateParams.cs b/src/Orb/Models/Coupons/CouponCreateParams.cs index dd7f76778..9c4238e24 100644 --- a/src/Orb/Models/Coupons/CouponCreateParams.cs +++ b/src/Orb/Models/Coupons/CouponCreateParams.cs @@ -482,8 +482,11 @@ public Percentage() this.DiscountType = JsonSerializer.SerializeToElement("percentage"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percentage(Percentage percentage) : base(percentage) { } +#pragma warning restore CS8618 public Percentage(IReadOnlyDictionary rawData) { @@ -559,8 +562,11 @@ public Amount() this.DiscountType = JsonSerializer.SerializeToElement("amount"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Amount(Amount amount) : base(amount) { } +#pragma warning restore CS8618 public Amount(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Coupons/CouponListPageResponse.cs b/src/Orb/Models/Coupons/CouponListPageResponse.cs index e6949cce7..a6540f7e2 100644 --- a/src/Orb/Models/Coupons/CouponListPageResponse.cs +++ b/src/Orb/Models/Coupons/CouponListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public CouponListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponListPageResponse(CouponListPageResponse couponListPageResponse) : base(couponListPageResponse) { } +#pragma warning restore CS8618 public CouponListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs index a8c8534a5..dc2c89198 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs @@ -122,8 +122,11 @@ public override void Validate() public CreditBlockRetrieveResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditBlockRetrieveResponse(CreditBlockRetrieveResponse creditBlockRetrieveResponse) : base(creditBlockRetrieveResponse) { } +#pragma warning restore CS8618 public CreditBlockRetrieveResponse(IReadOnlyDictionary rawData) { @@ -213,8 +216,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CreditNoteTiny.cs b/src/Orb/Models/CreditNoteTiny.cs index 1eab53361..e21aaf634 100644 --- a/src/Orb/Models/CreditNoteTiny.cs +++ b/src/Orb/Models/CreditNoteTiny.cs @@ -31,8 +31,11 @@ public override void Validate() public CreditNoteTiny() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNoteTiny(CreditNoteTiny creditNoteTiny) : base(creditNoteTiny) { } +#pragma warning restore CS8618 public CreditNoteTiny(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs index 74d00a8e4..92d95b4b4 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs @@ -304,8 +304,11 @@ public override void Validate() public LineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LineItem(LineItem lineItem) : base(lineItem) { } +#pragma warning restore CS8618 public LineItem(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CreditNotes/CreditNoteListPageResponse.cs b/src/Orb/Models/CreditNotes/CreditNoteListPageResponse.cs index 200e2513d..7056b930e 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteListPageResponse.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteListPageResponse.cs @@ -51,8 +51,11 @@ public override void Validate() public CreditNoteListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNoteListPageResponse(CreditNoteListPageResponse creditNoteListPageResponse) : base(creditNoteListPageResponse) { } +#pragma warning restore CS8618 public CreditNoteListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CustomExpiration.cs b/src/Orb/Models/CustomExpiration.cs index 2ad42030d..72c7c8928 100644 --- a/src/Orb/Models/CustomExpiration.cs +++ b/src/Orb/Models/CustomExpiration.cs @@ -43,8 +43,11 @@ public override void Validate() public CustomExpiration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomExpiration(CustomExpiration customExpiration) : base(customExpiration) { } +#pragma warning restore CS8618 public CustomExpiration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CustomerMinified.cs b/src/Orb/Models/CustomerMinified.cs index 9fa5b6d21..80582820d 100644 --- a/src/Orb/Models/CustomerMinified.cs +++ b/src/Orb/Models/CustomerMinified.cs @@ -39,8 +39,11 @@ public override void Validate() public CustomerMinified() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerMinified(CustomerMinified customerMinified) : base(customerMinified) { } +#pragma warning restore CS8618 public CustomerMinified(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CustomerTaxID.cs b/src/Orb/Models/CustomerTaxID.cs index 3945d0562..6fa3b8bd5 100644 --- a/src/Orb/Models/CustomerTaxID.cs +++ b/src/Orb/Models/CustomerTaxID.cs @@ -152,8 +152,11 @@ public override void Validate() public CustomerTaxID() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerTaxID(CustomerTaxID customerTaxID) : base(customerTaxID) { } +#pragma warning restore CS8618 public CustomerTaxID(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/AccountingProviderConfig.cs b/src/Orb/Models/Customers/AccountingProviderConfig.cs index a10b1a4d5..7e3b9482c 100644 --- a/src/Orb/Models/Customers/AccountingProviderConfig.cs +++ b/src/Orb/Models/Customers/AccountingProviderConfig.cs @@ -41,8 +41,11 @@ public override void Validate() public AccountingProviderConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AccountingProviderConfig(AccountingProviderConfig accountingProviderConfig) : base(accountingProviderConfig) { } +#pragma warning restore CS8618 public AccountingProviderConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/AddressInput.cs b/src/Orb/Models/Customers/AddressInput.cs index 5fa5faa37..d7a10513c 100644 --- a/src/Orb/Models/Customers/AddressInput.cs +++ b/src/Orb/Models/Customers/AddressInput.cs @@ -83,8 +83,11 @@ public override void Validate() public AddressInput() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddressInput(AddressInput addressInput) : base(addressInput) { } +#pragma warning restore CS8618 public AddressInput(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs index 3ebf70c79..cc56b8690 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs @@ -155,10 +155,13 @@ public override void Validate() public BalanceTransactionCreateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionCreateResponse( BalanceTransactionCreateResponse balanceTransactionCreateResponse ) : base(balanceTransactionCreateResponse) { } +#pragma warning restore CS8618 public BalanceTransactionCreateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponse.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponse.cs index a0500d53c..610cef923 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponse.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public BalanceTransactionListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionListPageResponse( BalanceTransactionListPageResponse balanceTransactionListPageResponse ) : base(balanceTransactionListPageResponse) { } +#pragma warning restore CS8618 public BalanceTransactionListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListResponse.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListResponse.cs index af2f33c65..15c27afa6 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListResponse.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListResponse.cs @@ -157,10 +157,13 @@ public override void Validate() public BalanceTransactionListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionListResponse( BalanceTransactionListResponse balanceTransactionListResponse ) : base(balanceTransactionListResponse) { } +#pragma warning restore CS8618 public BalanceTransactionListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Costs/CostListByExternalIDResponse.cs b/src/Orb/Models/Customers/Costs/CostListByExternalIDResponse.cs index 48f209bf4..7765fd64c 100644 --- a/src/Orb/Models/Customers/Costs/CostListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Costs/CostListByExternalIDResponse.cs @@ -40,8 +40,11 @@ public override void Validate() public CostListByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CostListByExternalIDResponse(CostListByExternalIDResponse costListByExternalIDResponse) : base(costListByExternalIDResponse) { } +#pragma warning restore CS8618 public CostListByExternalIDResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Costs/CostListResponse.cs b/src/Orb/Models/Customers/Costs/CostListResponse.cs index 8ebf6a663..5aa7ccf33 100644 --- a/src/Orb/Models/Customers/Costs/CostListResponse.cs +++ b/src/Orb/Models/Customers/Costs/CostListResponse.cs @@ -38,8 +38,11 @@ public override void Validate() public CostListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CostListResponse(CostListResponse costListResponse) : base(costListResponse) { } +#pragma warning restore CS8618 public CostListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponse.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponse.cs index d9f35364a..61ab411da 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public CreditListByExternalIDPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDPageResponse( CreditListByExternalIDPageResponse creditListByExternalIDPageResponse ) : base(creditListByExternalIDPageResponse) { } +#pragma warning restore CS8618 public CreditListByExternalIDPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs index db3834dec..5d8d6a1e1 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs @@ -126,10 +126,13 @@ public override void Validate() public CreditListByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDResponse( CreditListByExternalIDResponse creditListByExternalIDResponse ) : base(creditListByExternalIDResponse) { } +#pragma warning restore CS8618 public CreditListByExternalIDResponse(IReadOnlyDictionary rawData) { @@ -231,10 +234,13 @@ public override void Validate() public CreditListByExternalIDResponseFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDResponseFilter( CreditListByExternalIDResponseFilter creditListByExternalIDResponseFilter ) : base(creditListByExternalIDResponseFilter) { } +#pragma warning restore CS8618 public CreditListByExternalIDResponseFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/CreditListPageResponse.cs b/src/Orb/Models/Customers/Credits/CreditListPageResponse.cs index 67278ba97..328236e6b 100644 --- a/src/Orb/Models/Customers/Credits/CreditListPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public CreditListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListPageResponse(CreditListPageResponse creditListPageResponse) : base(creditListPageResponse) { } +#pragma warning restore CS8618 public CreditListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/CreditListResponse.cs b/src/Orb/Models/Customers/Credits/CreditListResponse.cs index d7ce8b6bf..e0dd4cfce 100644 --- a/src/Orb/Models/Customers/Credits/CreditListResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListResponse.cs @@ -117,8 +117,11 @@ public override void Validate() public CreditListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListResponse(CreditListResponse creditListResponse) : base(creditListResponse) { } +#pragma warning restore CS8618 public CreditListResponse(IReadOnlyDictionary rawData) { @@ -210,8 +213,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/AffectedBlock.cs b/src/Orb/Models/Customers/Credits/Ledger/AffectedBlock.cs index 6457653a9..5b49ce607 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/AffectedBlock.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/AffectedBlock.cs @@ -73,8 +73,11 @@ public override void Validate() public AffectedBlock() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AffectedBlock(AffectedBlock affectedBlock) : base(affectedBlock) { } +#pragma warning restore CS8618 public AffectedBlock(IReadOnlyDictionary rawData) { @@ -165,8 +168,11 @@ public override void Validate() public AffectedBlockFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AffectedBlockFilter(AffectedBlockFilter affectedBlockFilter) : base(affectedBlockFilter) { } +#pragma warning restore CS8618 public AffectedBlockFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/AmendmentLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/AmendmentLedgerEntry.cs index 3b1878b2e..d6fdce2b4 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/AmendmentLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/AmendmentLedgerEntry.cs @@ -178,8 +178,11 @@ public override void Validate() public AmendmentLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AmendmentLedgerEntry(AmendmentLedgerEntry amendmentLedgerEntry) : base(amendmentLedgerEntry) { } +#pragma warning restore CS8618 public AmendmentLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntry.cs index 489750a64..1e9e7088f 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntry.cs @@ -180,8 +180,11 @@ public override void Validate() public CreditBlockExpiryLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditBlockExpiryLedgerEntry(CreditBlockExpiryLedgerEntry creditBlockExpiryLedgerEntry) : base(creditBlockExpiryLedgerEntry) { } +#pragma warning restore CS8618 public CreditBlockExpiryLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs index af8ec446d..795411e5f 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs @@ -211,8 +211,11 @@ public override void Validate() public DecrementLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DecrementLedgerEntry(DecrementLedgerEntry decrementLedgerEntry) : base(decrementLedgerEntry) { } +#pragma warning restore CS8618 public DecrementLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntry.cs index 08ef51ecf..37a54c780 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntry.cs @@ -191,8 +191,11 @@ public override void Validate() public ExpirationChangeLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExpirationChangeLedgerEntry(ExpirationChangeLedgerEntry expirationChangeLedgerEntry) : base(expirationChangeLedgerEntry) { } +#pragma warning restore CS8618 public ExpirationChangeLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/IncrementLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/IncrementLedgerEntry.cs index 8325df4e1..42cbeb6aa 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/IncrementLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/IncrementLedgerEntry.cs @@ -202,8 +202,11 @@ public override void Validate() public IncrementLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public IncrementLedgerEntry(IncrementLedgerEntry incrementLedgerEntry) : base(incrementLedgerEntry) { } +#pragma warning restore CS8618 public IncrementLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index 77de4183d..a77c6efc9 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -1012,10 +1012,13 @@ public LedgerCreateEntryByExternalIDParamsBodyIncrement() this.EntryType = JsonSerializer.SerializeToElement("increment"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyIncrement( LedgerCreateEntryByExternalIDParamsBodyIncrement ledgerCreateEntryByExternalIDParamsBodyIncrement ) : base(ledgerCreateEntryByExternalIDParamsBodyIncrement) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyIncrement( IReadOnlyDictionary rawData @@ -1135,10 +1138,13 @@ public override void Validate() public LedgerCreateEntryByExternalIDParamsBodyIncrementFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyIncrementFilter( LedgerCreateEntryByExternalIDParamsBodyIncrementFilter ledgerCreateEntryByExternalIDParamsBodyIncrementFilter ) : base(ledgerCreateEntryByExternalIDParamsBodyIncrementFilter) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyIncrementFilter( IReadOnlyDictionary rawData @@ -1412,10 +1418,13 @@ public override void Validate() public LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings( LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings ledgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings ) : base(ledgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings( IReadOnlyDictionary rawData @@ -2074,10 +2083,13 @@ public LedgerCreateEntryByExternalIDParamsBodyDecrement() this.EntryType = JsonSerializer.SerializeToElement("decrement"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyDecrement( LedgerCreateEntryByExternalIDParamsBodyDecrement ledgerCreateEntryByExternalIDParamsBodyDecrement ) : base(ledgerCreateEntryByExternalIDParamsBodyDecrement) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyDecrement( IReadOnlyDictionary rawData @@ -2271,10 +2283,13 @@ public LedgerCreateEntryByExternalIDParamsBodyExpirationChange() this.EntryType = JsonSerializer.SerializeToElement("expiration_change"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyExpirationChange( LedgerCreateEntryByExternalIDParamsBodyExpirationChange ledgerCreateEntryByExternalIDParamsBodyExpirationChange ) : base(ledgerCreateEntryByExternalIDParamsBodyExpirationChange) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyExpirationChange( IReadOnlyDictionary rawData @@ -2450,10 +2465,13 @@ public LedgerCreateEntryByExternalIDParamsBodyVoid() this.EntryType = JsonSerializer.SerializeToElement("void"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyVoid( LedgerCreateEntryByExternalIDParamsBodyVoid ledgerCreateEntryByExternalIDParamsBodyVoid ) : base(ledgerCreateEntryByExternalIDParamsBodyVoid) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyVoid( IReadOnlyDictionary rawData @@ -2649,10 +2667,13 @@ public LedgerCreateEntryByExternalIDParamsBodyAmendment() this.EntryType = JsonSerializer.SerializeToElement("amendment"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyAmendment( LedgerCreateEntryByExternalIDParamsBodyAmendment ledgerCreateEntryByExternalIDParamsBodyAmendment ) : base(ledgerCreateEntryByExternalIDParamsBodyAmendment) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyAmendment( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index d2a7a00b2..0cedeb751 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -928,8 +928,11 @@ public Increment() this.EntryType = JsonSerializer.SerializeToElement("increment"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Increment(Increment increment) : base(increment) { } +#pragma warning restore CS8618 public Increment(IReadOnlyDictionary rawData) { @@ -1028,8 +1031,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -1273,8 +1279,11 @@ public override void Validate() public InvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceSettings(InvoiceSettings invoiceSettings) : base(invoiceSettings) { } +#pragma warning restore CS8618 public InvoiceSettings(IReadOnlyDictionary rawData) { @@ -1876,8 +1885,11 @@ public Decrement() this.EntryType = JsonSerializer.SerializeToElement("decrement"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Decrement(Decrement decrement) : base(decrement) { } +#pragma warning restore CS8618 public Decrement(IReadOnlyDictionary rawData) { @@ -2060,8 +2072,11 @@ public ExpirationChange() this.EntryType = JsonSerializer.SerializeToElement("expiration_change"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExpirationChange(ExpirationChange expirationChange) : base(expirationChange) { } +#pragma warning restore CS8618 public ExpirationChange(IReadOnlyDictionary rawData) { @@ -2224,8 +2239,11 @@ public Void() this.EntryType = JsonSerializer.SerializeToElement("void"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Void(Void void_) : base(void_) { } +#pragma warning restore CS8618 public Void(IReadOnlyDictionary rawData) { @@ -2409,8 +2427,11 @@ public Amendment() this.EntryType = JsonSerializer.SerializeToElement("amendment"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Amendment(Amendment amendment) : base(amendment) { } +#pragma warning restore CS8618 public Amendment(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponse.cs index 5bda979ed..33a90f0d4 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public LedgerListByExternalIDPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListByExternalIDPageResponse( LedgerListByExternalIDPageResponse ledgerListByExternalIDPageResponse ) : base(ledgerListByExternalIDPageResponse) { } +#pragma warning restore CS8618 public LedgerListByExternalIDPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPageResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPageResponse.cs index 374ccf577..9170fdbe1 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public LedgerListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListPageResponse(LedgerListPageResponse ledgerListPageResponse) : base(ledgerListPageResponse) { } +#pragma warning restore CS8618 public LedgerListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntry.cs index af6fb1fcf..6190085d9 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntry.cs @@ -213,8 +213,11 @@ public override void Validate() public VoidInitiatedLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public VoidInitiatedLedgerEntry(VoidInitiatedLedgerEntry voidInitiatedLedgerEntry) : base(voidInitiatedLedgerEntry) { } +#pragma warning restore CS8618 public VoidInitiatedLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/VoidLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/VoidLedgerEntry.cs index dc391a7b7..30047428c 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/VoidLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/VoidLedgerEntry.cs @@ -200,8 +200,11 @@ public override void Validate() public VoidLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public VoidLedgerEntry(VoidLedgerEntry voidLedgerEntry) : base(voidLedgerEntry) { } +#pragma warning restore CS8618 public VoidLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs index 0b32a35bb..ef541d4c2 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs @@ -352,10 +352,13 @@ public override void Validate() public TopUpCreateByExternalIDParamsInvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateByExternalIDParamsInvoiceSettings( TopUpCreateByExternalIDParamsInvoiceSettings topUpCreateByExternalIDParamsInvoiceSettings ) : base(topUpCreateByExternalIDParamsInvoiceSettings) { } +#pragma warning restore CS8618 public TopUpCreateByExternalIDParamsInvoiceSettings( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponse.cs index 3dac5357b..c947f056f 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponse.cs @@ -138,10 +138,13 @@ public override void Validate() public TopUpCreateByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateByExternalIDResponse( TopUpCreateByExternalIDResponse topUpCreateByExternalIDResponse ) : base(topUpCreateByExternalIDResponse) { } +#pragma warning restore CS8618 public TopUpCreateByExternalIDResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs index 8d310fcb0..5f9b3e297 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs @@ -337,8 +337,11 @@ public override void Validate() public InvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceSettings(InvoiceSettings invoiceSettings) : base(invoiceSettings) { } +#pragma warning restore CS8618 public InvoiceSettings(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateResponse.cs index 0342bbe41..d3e3630b8 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateResponse.cs @@ -133,8 +133,11 @@ public override void Validate() public TopUpCreateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateResponse(TopUpCreateResponse topUpCreateResponse) : base(topUpCreateResponse) { } +#pragma warning restore CS8618 public TopUpCreateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpInvoiceSettings.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpInvoiceSettings.cs index c40b7b227..e7ec8a8f8 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpInvoiceSettings.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpInvoiceSettings.cs @@ -87,8 +87,11 @@ public override void Validate() public TopUpInvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpInvoiceSettings(TopUpInvoiceSettings topUpInvoiceSettings) : base(topUpInvoiceSettings) { } +#pragma warning restore CS8618 public TopUpInvoiceSettings(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponse.cs index a5f35dcab..3d857a2e2 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public TopUpListByExternalIDPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListByExternalIDPageResponse( TopUpListByExternalIDPageResponse topUpListByExternalIDPageResponse ) : base(topUpListByExternalIDPageResponse) { } +#pragma warning restore CS8618 public TopUpListByExternalIDPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponse.cs index 8af7cb784..b13179e16 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponse.cs @@ -135,10 +135,13 @@ public override void Validate() public TopUpListByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListByExternalIDResponse( TopUpListByExternalIDResponse topUpListByExternalIDResponse ) : base(topUpListByExternalIDResponse) { } +#pragma warning restore CS8618 public TopUpListByExternalIDResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPageResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPageResponse.cs index 70a6d2c75..3768fe050 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public TopUpListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListPageResponse(TopUpListPageResponse topUpListPageResponse) : base(topUpListPageResponse) { } +#pragma warning restore CS8618 public TopUpListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListResponse.cs index bd8a54a0f..9b6422446 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListResponse.cs @@ -133,8 +133,11 @@ public override void Validate() public TopUpListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListResponse(TopUpListResponse topUpListResponse) : base(topUpListResponse) { } +#pragma warning restore CS8618 public TopUpListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Customer.cs b/src/Orb/Models/Customers/Customer.cs index 286d65f48..d4cdfef9e 100644 --- a/src/Orb/Models/Customers/Customer.cs +++ b/src/Orb/Models/Customers/Customer.cs @@ -487,8 +487,11 @@ public override void Validate() public Customer() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Customer(Customer customer) : base(customer) { } +#pragma warning restore CS8618 public Customer(IReadOnlyDictionary rawData) { @@ -561,8 +564,11 @@ public override void Validate() public Hierarchy() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Hierarchy(Hierarchy hierarchy) : base(hierarchy) { } +#pragma warning restore CS8618 public Hierarchy(IReadOnlyDictionary rawData) { @@ -693,8 +699,11 @@ public override void Validate() public AccountingSyncConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AccountingSyncConfiguration(AccountingSyncConfiguration accountingSyncConfiguration) : base(accountingSyncConfiguration) { } +#pragma warning restore CS8618 public AccountingSyncConfiguration(IReadOnlyDictionary rawData) { @@ -760,8 +769,11 @@ public override void Validate() public AccountingProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AccountingProvider(AccountingProvider accountingProvider) : base(accountingProvider) { } +#pragma warning restore CS8618 public AccountingProvider(IReadOnlyDictionary rawData) { @@ -882,8 +894,11 @@ public override void Validate() public CustomerPaymentConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerPaymentConfiguration(CustomerPaymentConfiguration customerPaymentConfiguration) : base(customerPaymentConfiguration) { } +#pragma warning restore CS8618 public CustomerPaymentConfiguration(IReadOnlyDictionary rawData) { @@ -980,10 +995,13 @@ public override void Validate() public CustomerPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerPaymentConfigurationPaymentProvider( CustomerPaymentConfigurationPaymentProvider customerPaymentConfigurationPaymentProvider ) : base(customerPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -1093,8 +1111,11 @@ public override void Validate() public ReportingConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReportingConfiguration(ReportingConfiguration reportingConfiguration) : base(reportingConfiguration) { } +#pragma warning restore CS8618 public ReportingConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/CustomerCreateParams.cs b/src/Orb/Models/Customers/CustomerCreateParams.cs index 65d75f56c..75165aaee 100644 --- a/src/Orb/Models/Customers/CustomerCreateParams.cs +++ b/src/Orb/Models/Customers/CustomerCreateParams.cs @@ -567,8 +567,11 @@ public override void Validate() public PaymentConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PaymentConfiguration(PaymentConfiguration paymentConfiguration) : base(paymentConfiguration) { } +#pragma warning restore CS8618 public PaymentConfiguration(IReadOnlyDictionary rawData) { @@ -655,8 +658,11 @@ public override void Validate() public PaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PaymentProvider(PaymentProvider paymentProvider) : base(paymentProvider) { } +#pragma warning restore CS8618 public PaymentProvider(IReadOnlyDictionary rawData) { @@ -1384,8 +1390,11 @@ public Numeral() this.TaxProvider = JsonSerializer.SerializeToElement("numeral"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Numeral(Numeral numeral) : base(numeral) { } +#pragma warning restore CS8618 public Numeral(IReadOnlyDictionary rawData) { @@ -1476,8 +1485,11 @@ public Anrok() this.TaxProvider = JsonSerializer.SerializeToElement("anrok"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Anrok(Anrok anrok) : base(anrok) { } +#pragma warning restore CS8618 public Anrok(IReadOnlyDictionary rawData) { @@ -1568,8 +1580,11 @@ public Stripe() this.TaxProvider = JsonSerializer.SerializeToElement("stripe"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Stripe(Stripe stripe) : base(stripe) { } +#pragma warning restore CS8618 public Stripe(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/CustomerHierarchyConfig.cs b/src/Orb/Models/Customers/CustomerHierarchyConfig.cs index 2445c7712..22de7b71f 100644 --- a/src/Orb/Models/Customers/CustomerHierarchyConfig.cs +++ b/src/Orb/Models/Customers/CustomerHierarchyConfig.cs @@ -59,8 +59,11 @@ public override void Validate() public CustomerHierarchyConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerHierarchyConfig(CustomerHierarchyConfig customerHierarchyConfig) : base(customerHierarchyConfig) { } +#pragma warning restore CS8618 public CustomerHierarchyConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/CustomerListPageResponse.cs b/src/Orb/Models/Customers/CustomerListPageResponse.cs index 0faa054f7..4dcf9da9f 100644 --- a/src/Orb/Models/Customers/CustomerListPageResponse.cs +++ b/src/Orb/Models/Customers/CustomerListPageResponse.cs @@ -51,8 +51,11 @@ public override void Validate() public CustomerListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerListPageResponse(CustomerListPageResponse customerListPageResponse) : base(customerListPageResponse) { } +#pragma warning restore CS8618 public CustomerListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index e27bc465f..71db0fde8 100644 --- a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs @@ -567,10 +567,13 @@ public override void Validate() public CustomerUpdateByExternalIDParamsPaymentConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsPaymentConfiguration( CustomerUpdateByExternalIDParamsPaymentConfiguration customerUpdateByExternalIDParamsPaymentConfiguration ) : base(customerUpdateByExternalIDParamsPaymentConfiguration) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsPaymentConfiguration( IReadOnlyDictionary rawData @@ -676,10 +679,13 @@ public override void Validate() public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider( CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider customerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider ) : base(customerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -1488,10 +1494,13 @@ public CustomerUpdateByExternalIDParamsTaxConfigurationNumeral() this.TaxProvider = JsonSerializer.SerializeToElement("numeral"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsTaxConfigurationNumeral( CustomerUpdateByExternalIDParamsTaxConfigurationNumeral customerUpdateByExternalIDParamsTaxConfigurationNumeral ) : base(customerUpdateByExternalIDParamsTaxConfigurationNumeral) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsTaxConfigurationNumeral( IReadOnlyDictionary rawData @@ -1595,10 +1604,13 @@ public CustomerUpdateByExternalIDParamsTaxConfigurationAnrok() this.TaxProvider = JsonSerializer.SerializeToElement("anrok"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsTaxConfigurationAnrok( CustomerUpdateByExternalIDParamsTaxConfigurationAnrok customerUpdateByExternalIDParamsTaxConfigurationAnrok ) : base(customerUpdateByExternalIDParamsTaxConfigurationAnrok) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsTaxConfigurationAnrok( IReadOnlyDictionary rawData @@ -1702,10 +1714,13 @@ public CustomerUpdateByExternalIDParamsTaxConfigurationStripe() this.TaxProvider = JsonSerializer.SerializeToElement("stripe"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsTaxConfigurationStripe( CustomerUpdateByExternalIDParamsTaxConfigurationStripe customerUpdateByExternalIDParamsTaxConfigurationStripe ) : base(customerUpdateByExternalIDParamsTaxConfigurationStripe) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsTaxConfigurationStripe( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Customers/CustomerUpdateParams.cs b/src/Orb/Models/Customers/CustomerUpdateParams.cs index 7533d7c28..d46922d5c 100644 --- a/src/Orb/Models/Customers/CustomerUpdateParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateParams.cs @@ -566,10 +566,13 @@ public override void Validate() public CustomerUpdateParamsPaymentConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsPaymentConfiguration( CustomerUpdateParamsPaymentConfiguration customerUpdateParamsPaymentConfiguration ) : base(customerUpdateParamsPaymentConfiguration) { } +#pragma warning restore CS8618 public CustomerUpdateParamsPaymentConfiguration( IReadOnlyDictionary rawData @@ -669,10 +672,13 @@ public override void Validate() public CustomerUpdateParamsPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsPaymentConfigurationPaymentProvider( CustomerUpdateParamsPaymentConfigurationPaymentProvider customerUpdateParamsPaymentConfigurationPaymentProvider ) : base(customerUpdateParamsPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerUpdateParamsPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -1475,10 +1481,13 @@ public CustomerUpdateParamsTaxConfigurationNumeral() this.TaxProvider = JsonSerializer.SerializeToElement("numeral"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsTaxConfigurationNumeral( CustomerUpdateParamsTaxConfigurationNumeral customerUpdateParamsTaxConfigurationNumeral ) : base(customerUpdateParamsTaxConfigurationNumeral) { } +#pragma warning restore CS8618 public CustomerUpdateParamsTaxConfigurationNumeral( IReadOnlyDictionary rawData @@ -1580,10 +1589,13 @@ public CustomerUpdateParamsTaxConfigurationAnrok() this.TaxProvider = JsonSerializer.SerializeToElement("anrok"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsTaxConfigurationAnrok( CustomerUpdateParamsTaxConfigurationAnrok customerUpdateParamsTaxConfigurationAnrok ) : base(customerUpdateParamsTaxConfigurationAnrok) { } +#pragma warning restore CS8618 public CustomerUpdateParamsTaxConfigurationAnrok( IReadOnlyDictionary rawData @@ -1685,10 +1697,13 @@ public CustomerUpdateParamsTaxConfigurationStripe() this.TaxProvider = JsonSerializer.SerializeToElement("stripe"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsTaxConfigurationStripe( CustomerUpdateParamsTaxConfigurationStripe customerUpdateParamsTaxConfigurationStripe ) : base(customerUpdateParamsTaxConfigurationStripe) { } +#pragma warning restore CS8618 public CustomerUpdateParamsTaxConfigurationStripe( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Customers/NewAccountingSyncConfiguration.cs b/src/Orb/Models/Customers/NewAccountingSyncConfiguration.cs index cfc574684..45de781f1 100644 --- a/src/Orb/Models/Customers/NewAccountingSyncConfiguration.cs +++ b/src/Orb/Models/Customers/NewAccountingSyncConfiguration.cs @@ -56,10 +56,13 @@ public override void Validate() public NewAccountingSyncConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAccountingSyncConfiguration( NewAccountingSyncConfiguration newAccountingSyncConfiguration ) : base(newAccountingSyncConfiguration) { } +#pragma warning restore CS8618 public NewAccountingSyncConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/NewAvalaraTaxConfiguration.cs b/src/Orb/Models/Customers/NewAvalaraTaxConfiguration.cs index 59428dc6c..525a58b26 100644 --- a/src/Orb/Models/Customers/NewAvalaraTaxConfiguration.cs +++ b/src/Orb/Models/Customers/NewAvalaraTaxConfiguration.cs @@ -69,8 +69,11 @@ public override void Validate() public NewAvalaraTaxConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAvalaraTaxConfiguration(NewAvalaraTaxConfiguration newAvalaraTaxConfiguration) : base(newAvalaraTaxConfiguration) { } +#pragma warning restore CS8618 public NewAvalaraTaxConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/NewReportingConfiguration.cs b/src/Orb/Models/Customers/NewReportingConfiguration.cs index 2396d1936..bd38dd6af 100644 --- a/src/Orb/Models/Customers/NewReportingConfiguration.cs +++ b/src/Orb/Models/Customers/NewReportingConfiguration.cs @@ -30,8 +30,11 @@ public override void Validate() public NewReportingConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewReportingConfiguration(NewReportingConfiguration newReportingConfiguration) : base(newReportingConfiguration) { } +#pragma warning restore CS8618 public NewReportingConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/NewSphereConfiguration.cs b/src/Orb/Models/Customers/NewSphereConfiguration.cs index 79acde7db..26ad1397e 100644 --- a/src/Orb/Models/Customers/NewSphereConfiguration.cs +++ b/src/Orb/Models/Customers/NewSphereConfiguration.cs @@ -58,8 +58,11 @@ public override void Validate() public NewSphereConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSphereConfiguration(NewSphereConfiguration newSphereConfiguration) : base(newSphereConfiguration) { } +#pragma warning restore CS8618 public NewSphereConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/NewTaxJarConfiguration.cs b/src/Orb/Models/Customers/NewTaxJarConfiguration.cs index a1300db26..e7af4c5af 100644 --- a/src/Orb/Models/Customers/NewTaxJarConfiguration.cs +++ b/src/Orb/Models/Customers/NewTaxJarConfiguration.cs @@ -58,8 +58,11 @@ public override void Validate() public NewTaxJarConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewTaxJarConfiguration(NewTaxJarConfiguration newTaxJarConfiguration) : base(newTaxJarConfiguration) { } +#pragma warning restore CS8618 public NewTaxJarConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/DimensionalPriceConfiguration.cs b/src/Orb/Models/DimensionalPriceConfiguration.cs index 4b77999b6..915e8b526 100644 --- a/src/Orb/Models/DimensionalPriceConfiguration.cs +++ b/src/Orb/Models/DimensionalPriceConfiguration.cs @@ -48,10 +48,13 @@ public override void Validate() public DimensionalPriceConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceConfiguration( DimensionalPriceConfiguration dimensionalPriceConfiguration ) : base(dimensionalPriceConfiguration) { } +#pragma warning restore CS8618 public DimensionalPriceConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs index e349bd7f9..73e3a7199 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs @@ -121,8 +121,11 @@ public override void Validate() public DimensionalPriceGroup() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroup(DimensionalPriceGroup dimensionalPriceGroup) : base(dimensionalPriceGroup) { } +#pragma warning restore CS8618 public DimensionalPriceGroup(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroups.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroups.cs index 29adb7e1d..a5380f092 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroups.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroups.cs @@ -54,10 +54,13 @@ public override void Validate() public DimensionalPriceGroupDimensionalPriceGroups() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupDimensionalPriceGroups( DimensionalPriceGroupDimensionalPriceGroups dimensionalPriceGroupDimensionalPriceGroups ) : base(dimensionalPriceGroupDimensionalPriceGroups) { } +#pragma warning restore CS8618 public DimensionalPriceGroupDimensionalPriceGroups( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Events/Backfills/BackfillCloseResponse.cs b/src/Orb/Models/Events/Backfills/BackfillCloseResponse.cs index dc13dfed5..502669e9a 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCloseResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCloseResponse.cs @@ -172,8 +172,11 @@ public override void Validate() public BackfillCloseResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillCloseResponse(BackfillCloseResponse backfillCloseResponse) : base(backfillCloseResponse) { } +#pragma warning restore CS8618 public BackfillCloseResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs b/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs index 686a4118b..36ffce44f 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs @@ -170,8 +170,11 @@ public override void Validate() public BackfillCreateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillCreateResponse(BackfillCreateResponse backfillCreateResponse) : base(backfillCreateResponse) { } +#pragma warning restore CS8618 public BackfillCreateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillFetchResponse.cs b/src/Orb/Models/Events/Backfills/BackfillFetchResponse.cs index 8015f7326..9e22f8ed9 100644 --- a/src/Orb/Models/Events/Backfills/BackfillFetchResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillFetchResponse.cs @@ -172,8 +172,11 @@ public override void Validate() public BackfillFetchResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillFetchResponse(BackfillFetchResponse backfillFetchResponse) : base(backfillFetchResponse) { } +#pragma warning restore CS8618 public BackfillFetchResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillListPageResponse.cs b/src/Orb/Models/Events/Backfills/BackfillListPageResponse.cs index a7fbc7f21..a54bd5ddb 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListPageResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListPageResponse.cs @@ -51,8 +51,11 @@ public override void Validate() public BackfillListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillListPageResponse(BackfillListPageResponse backfillListPageResponse) : base(backfillListPageResponse) { } +#pragma warning restore CS8618 public BackfillListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillListResponse.cs b/src/Orb/Models/Events/Backfills/BackfillListResponse.cs index f5702c641..a90adbc90 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListResponse.cs @@ -172,8 +172,11 @@ public override void Validate() public BackfillListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillListResponse(BackfillListResponse backfillListResponse) : base(backfillListResponse) { } +#pragma warning restore CS8618 public BackfillListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillRevertResponse.cs b/src/Orb/Models/Events/Backfills/BackfillRevertResponse.cs index b427f82e9..b67f7298b 100644 --- a/src/Orb/Models/Events/Backfills/BackfillRevertResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillRevertResponse.cs @@ -172,8 +172,11 @@ public override void Validate() public BackfillRevertResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillRevertResponse(BackfillRevertResponse backfillRevertResponse) : base(backfillRevertResponse) { } +#pragma warning restore CS8618 public BackfillRevertResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventDeprecateResponse.cs b/src/Orb/Models/Events/EventDeprecateResponse.cs index 22151fd23..0a5793a09 100644 --- a/src/Orb/Models/Events/EventDeprecateResponse.cs +++ b/src/Orb/Models/Events/EventDeprecateResponse.cs @@ -31,8 +31,11 @@ public override void Validate() public EventDeprecateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventDeprecateResponse(EventDeprecateResponse eventDeprecateResponse) : base(eventDeprecateResponse) { } +#pragma warning restore CS8618 public EventDeprecateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventIngestParams.cs b/src/Orb/Models/Events/EventIngestParams.cs index 04b688bae..9cdbd6055 100644 --- a/src/Orb/Models/Events/EventIngestParams.cs +++ b/src/Orb/Models/Events/EventIngestParams.cs @@ -450,8 +450,11 @@ public override void Validate() public Event() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Event(Event event_) : base(event_) { } +#pragma warning restore CS8618 public Event(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventIngestResponse.cs b/src/Orb/Models/Events/EventIngestResponse.cs index 88e52d753..f360128ea 100644 --- a/src/Orb/Models/Events/EventIngestResponse.cs +++ b/src/Orb/Models/Events/EventIngestResponse.cs @@ -59,8 +59,11 @@ public override void Validate() public EventIngestResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventIngestResponse(EventIngestResponse eventIngestResponse) : base(eventIngestResponse) { } +#pragma warning restore CS8618 public EventIngestResponse(IReadOnlyDictionary rawData) { @@ -142,8 +145,11 @@ public override void Validate() public ValidationFailed() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ValidationFailed(ValidationFailed validationFailed) : base(validationFailed) { } +#pragma warning restore CS8618 public ValidationFailed(IReadOnlyDictionary rawData) { @@ -222,8 +228,11 @@ public override void Validate() public Debug() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Debug(Debug debug) : base(debug) { } +#pragma warning restore CS8618 public Debug(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventSearchResponse.cs b/src/Orb/Models/Events/EventSearchResponse.cs index d72519af7..2f1419d72 100644 --- a/src/Orb/Models/Events/EventSearchResponse.cs +++ b/src/Orb/Models/Events/EventSearchResponse.cs @@ -36,8 +36,11 @@ public override void Validate() public EventSearchResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventSearchResponse(EventSearchResponse eventSearchResponse) : base(eventSearchResponse) { } +#pragma warning restore CS8618 public EventSearchResponse(IReadOnlyDictionary rawData) { @@ -201,8 +204,11 @@ public override void Validate() public Data() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Data(Data data) : base(data) { } +#pragma warning restore CS8618 public Data(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventUpdateResponse.cs b/src/Orb/Models/Events/EventUpdateResponse.cs index 4005fedf2..15fd3f0bc 100644 --- a/src/Orb/Models/Events/EventUpdateResponse.cs +++ b/src/Orb/Models/Events/EventUpdateResponse.cs @@ -31,8 +31,11 @@ public override void Validate() public EventUpdateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventUpdateResponse(EventUpdateResponse eventUpdateResponse) : base(eventUpdateResponse) { } +#pragma warning restore CS8618 public EventUpdateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Volume/EventVolumes.cs b/src/Orb/Models/Events/Volume/EventVolumes.cs index bd74c288e..cea58a513 100644 --- a/src/Orb/Models/Events/Volume/EventVolumes.cs +++ b/src/Orb/Models/Events/Volume/EventVolumes.cs @@ -36,8 +36,11 @@ public override void Validate() public EventVolumes() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventVolumes(EventVolumes eventVolumes) : base(eventVolumes) { } +#pragma warning restore CS8618 public EventVolumes(IReadOnlyDictionary rawData) { @@ -123,8 +126,11 @@ public override void Validate() public Data() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Data(Data data) : base(data) { } +#pragma warning restore CS8618 public Data(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/FixedFeeQuantityScheduleEntry.cs b/src/Orb/Models/FixedFeeQuantityScheduleEntry.cs index c6a6f8b05..d38069da1 100644 --- a/src/Orb/Models/FixedFeeQuantityScheduleEntry.cs +++ b/src/Orb/Models/FixedFeeQuantityScheduleEntry.cs @@ -64,10 +64,13 @@ public override void Validate() public FixedFeeQuantityScheduleEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public FixedFeeQuantityScheduleEntry( FixedFeeQuantityScheduleEntry fixedFeeQuantityScheduleEntry ) : base(fixedFeeQuantityScheduleEntry) { } +#pragma warning restore CS8618 public FixedFeeQuantityScheduleEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/FixedFeeQuantityTransition.cs b/src/Orb/Models/FixedFeeQuantityTransition.cs index d964ab0ce..d3760050e 100644 --- a/src/Orb/Models/FixedFeeQuantityTransition.cs +++ b/src/Orb/Models/FixedFeeQuantityTransition.cs @@ -53,8 +53,11 @@ public override void Validate() public FixedFeeQuantityTransition() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public FixedFeeQuantityTransition(FixedFeeQuantityTransition fixedFeeQuantityTransition) : base(fixedFeeQuantityTransition) { } +#pragma warning restore CS8618 public FixedFeeQuantityTransition(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoice.cs b/src/Orb/Models/Invoice.cs index 55e12542c..ac6104927 100644 --- a/src/Orb/Models/Invoice.cs +++ b/src/Orb/Models/Invoice.cs @@ -747,9 +747,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: discount")] public Invoice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: discount")] public Invoice(Invoice invoice) : base(invoice) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: discount")] public Invoice(IReadOnlyDictionary rawData) @@ -855,8 +858,11 @@ public override void Validate() public InvoiceAutoCollection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceAutoCollection(InvoiceAutoCollection invoiceAutoCollection) : base(invoiceAutoCollection) { } +#pragma warning restore CS8618 public InvoiceAutoCollection(IReadOnlyDictionary rawData) { @@ -982,8 +988,11 @@ public override void Validate() public InvoiceCreditNote() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceCreditNote(InvoiceCreditNote invoiceCreditNote) : base(invoiceCreditNote) { } +#pragma warning restore CS8618 public InvoiceCreditNote(IReadOnlyDictionary rawData) { @@ -1162,10 +1171,13 @@ public override void Validate() public InvoiceCustomerBalanceTransaction() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceCustomerBalanceTransaction( InvoiceCustomerBalanceTransaction invoiceCustomerBalanceTransaction ) : base(invoiceCustomerBalanceTransaction) { } +#pragma warning restore CS8618 public InvoiceCustomerBalanceTransaction(IReadOnlyDictionary rawData) { @@ -1663,8 +1675,11 @@ public override void Validate() public InvoiceLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceLineItem(InvoiceLineItem invoiceLineItem) : base(invoiceLineItem) { } +#pragma warning restore CS8618 public InvoiceLineItem(IReadOnlyDictionary rawData) { @@ -2731,8 +2746,11 @@ public override void Validate() public InvoicePaymentAttempt() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoicePaymentAttempt(InvoicePaymentAttempt invoicePaymentAttempt) : base(invoicePaymentAttempt) { } +#pragma warning restore CS8618 public InvoicePaymentAttempt(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs index d34fc7c74..1a2d621ee 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs @@ -309,10 +309,13 @@ public override void Validate() public InvoiceLineItemCreateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceLineItemCreateResponse( InvoiceLineItemCreateResponse invoiceLineItemCreateResponse ) : base(invoiceLineItemCreateResponse) { } +#pragma warning restore CS8618 public InvoiceLineItemCreateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/InvoiceTiny.cs b/src/Orb/Models/InvoiceTiny.cs index ed3bf0a69..2f2c38ff0 100644 --- a/src/Orb/Models/InvoiceTiny.cs +++ b/src/Orb/Models/InvoiceTiny.cs @@ -31,8 +31,11 @@ public override void Validate() public InvoiceTiny() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceTiny(InvoiceTiny invoiceTiny) : base(invoiceTiny) { } +#pragma warning restore CS8618 public InvoiceTiny(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoices/InvoiceCreateParams.cs b/src/Orb/Models/Invoices/InvoiceCreateParams.cs index e78d79d3d..054c36a79 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -410,8 +410,11 @@ public override void Validate() public LineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LineItem(LineItem lineItem) : base(lineItem) { } +#pragma warning restore CS8618 public LineItem(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs index a398e2e80..952adaca7 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs @@ -742,9 +742,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: discount")] public InvoiceFetchUpcomingResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: discount")] public InvoiceFetchUpcomingResponse(InvoiceFetchUpcomingResponse invoiceFetchUpcomingResponse) : base(invoiceFetchUpcomingResponse) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: discount")] public InvoiceFetchUpcomingResponse(IReadOnlyDictionary rawData) @@ -853,8 +856,11 @@ public override void Validate() public AutoCollection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AutoCollection(AutoCollection autoCollection) : base(autoCollection) { } +#pragma warning restore CS8618 public AutoCollection(IReadOnlyDictionary rawData) { @@ -977,8 +983,11 @@ public override void Validate() public CreditNote() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNote(CreditNote creditNote) : base(creditNote) { } +#pragma warning restore CS8618 public CreditNote(IReadOnlyDictionary rawData) { @@ -1150,8 +1159,11 @@ public override void Validate() public CustomerBalanceTransaction() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerBalanceTransaction(CustomerBalanceTransaction customerBalanceTransaction) : base(customerBalanceTransaction) { } +#pragma warning restore CS8618 public CustomerBalanceTransaction(IReadOnlyDictionary rawData) { @@ -1640,10 +1652,13 @@ public override void Validate() public InvoiceFetchUpcomingResponseLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceFetchUpcomingResponseLineItem( InvoiceFetchUpcomingResponseLineItem invoiceFetchUpcomingResponseLineItem ) : base(invoiceFetchUpcomingResponseLineItem) { } +#pragma warning restore CS8618 public InvoiceFetchUpcomingResponseLineItem(IReadOnlyDictionary rawData) { @@ -2685,8 +2700,11 @@ public override void Validate() public PaymentAttempt() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PaymentAttempt(PaymentAttempt paymentAttempt) : base(paymentAttempt) { } +#pragma warning restore CS8618 public PaymentAttempt(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoices/InvoiceListPageResponse.cs b/src/Orb/Models/Invoices/InvoiceListPageResponse.cs index 4c9bf2b41..830c24b93 100644 --- a/src/Orb/Models/Invoices/InvoiceListPageResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public InvoiceListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListPageResponse(InvoiceListPageResponse invoiceListPageResponse) : base(invoiceListPageResponse) { } +#pragma warning restore CS8618 public InvoiceListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryPageResponse.cs b/src/Orb/Models/Invoices/InvoiceListSummaryPageResponse.cs index c8970d611..7ad2539f5 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryPageResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public InvoiceListSummaryPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryPageResponse( InvoiceListSummaryPageResponse invoiceListSummaryPageResponse ) : base(invoiceListSummaryPageResponse) { } +#pragma warning restore CS8618 public InvoiceListSummaryPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs b/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs index d5c4dfe40..dc1187a9e 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs @@ -628,8 +628,11 @@ public override void Validate() public InvoiceListSummaryResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponse(InvoiceListSummaryResponse invoiceListSummaryResponse) : base(invoiceListSummaryResponse) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponse(IReadOnlyDictionary rawData) { @@ -741,10 +744,13 @@ public override void Validate() public InvoiceListSummaryResponseAutoCollection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponseAutoCollection( InvoiceListSummaryResponseAutoCollection invoiceListSummaryResponseAutoCollection ) : base(invoiceListSummaryResponseAutoCollection) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponseAutoCollection( IReadOnlyDictionary rawData @@ -878,10 +884,13 @@ public override void Validate() public InvoiceListSummaryResponseCreditNote() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponseCreditNote( InvoiceListSummaryResponseCreditNote invoiceListSummaryResponseCreditNote ) : base(invoiceListSummaryResponseCreditNote) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponseCreditNote(IReadOnlyDictionary rawData) { @@ -1065,10 +1074,13 @@ public override void Validate() public InvoiceListSummaryResponseCustomerBalanceTransaction() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponseCustomerBalanceTransaction( InvoiceListSummaryResponseCustomerBalanceTransaction invoiceListSummaryResponseCustomerBalanceTransaction ) : base(invoiceListSummaryResponseCustomerBalanceTransaction) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponseCustomerBalanceTransaction( IReadOnlyDictionary rawData @@ -1406,10 +1418,13 @@ public override void Validate() public InvoiceListSummaryResponsePaymentAttempt() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponsePaymentAttempt( InvoiceListSummaryResponsePaymentAttempt invoiceListSummaryResponsePaymentAttempt ) : base(invoiceListSummaryResponsePaymentAttempt) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponsePaymentAttempt( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/ItemSlim.cs b/src/Orb/Models/ItemSlim.cs index 62da0419f..34f873937 100644 --- a/src/Orb/Models/ItemSlim.cs +++ b/src/Orb/Models/ItemSlim.cs @@ -48,8 +48,11 @@ public override void Validate() public ItemSlim() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemSlim(ItemSlim itemSlim) : base(itemSlim) { } +#pragma warning restore CS8618 public ItemSlim(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Items/Item.cs b/src/Orb/Models/Items/Item.cs index 7f83161d1..decfb3311 100644 --- a/src/Orb/Models/Items/Item.cs +++ b/src/Orb/Models/Items/Item.cs @@ -130,8 +130,11 @@ public override void Validate() public Item() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Item(Item item) : base(item) { } +#pragma warning restore CS8618 public Item(IReadOnlyDictionary rawData) { @@ -207,8 +210,11 @@ public override void Validate() public ItemExternalConnection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemExternalConnection(ItemExternalConnection itemExternalConnection) : base(itemExternalConnection) { } +#pragma warning restore CS8618 public ItemExternalConnection(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Items/ItemListPageResponse.cs b/src/Orb/Models/Items/ItemListPageResponse.cs index ceb712bc6..f922fbfe8 100644 --- a/src/Orb/Models/Items/ItemListPageResponse.cs +++ b/src/Orb/Models/Items/ItemListPageResponse.cs @@ -46,8 +46,11 @@ public override void Validate() public ItemListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemListPageResponse(ItemListPageResponse itemListPageResponse) : base(itemListPageResponse) { } +#pragma warning restore CS8618 public ItemListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Items/ItemUpdateParams.cs b/src/Orb/Models/Items/ItemUpdateParams.cs index 68ef65fd2..d30c3e356 100644 --- a/src/Orb/Models/Items/ItemUpdateParams.cs +++ b/src/Orb/Models/Items/ItemUpdateParams.cs @@ -234,8 +234,11 @@ public override void Validate() public ExternalConnection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalConnection(ExternalConnection externalConnection) : base(externalConnection) { } +#pragma warning restore CS8618 public ExternalConnection(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MatrixConfig.cs b/src/Orb/Models/MatrixConfig.cs index 4dd977f1d..511846519 100644 --- a/src/Orb/Models/MatrixConfig.cs +++ b/src/Orb/Models/MatrixConfig.cs @@ -78,8 +78,11 @@ public override void Validate() public MatrixConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixConfig(MatrixConfig matrixConfig) : base(matrixConfig) { } +#pragma warning restore CS8618 public MatrixConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MatrixSubLineItem.cs b/src/Orb/Models/MatrixSubLineItem.cs index e796b970c..b72ba2515 100644 --- a/src/Orb/Models/MatrixSubLineItem.cs +++ b/src/Orb/Models/MatrixSubLineItem.cs @@ -102,8 +102,11 @@ public override void Validate() public MatrixSubLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixSubLineItem(MatrixSubLineItem matrixSubLineItem) : base(matrixSubLineItem) { } +#pragma warning restore CS8618 public MatrixSubLineItem(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MatrixValue.cs b/src/Orb/Models/MatrixValue.cs index 52953c47f..1fb9a1ce4 100644 --- a/src/Orb/Models/MatrixValue.cs +++ b/src/Orb/Models/MatrixValue.cs @@ -55,8 +55,11 @@ public override void Validate() public MatrixValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixValue(MatrixValue matrixValue) : base(matrixValue) { } +#pragma warning restore CS8618 public MatrixValue(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MatrixWithAllocationConfig.cs b/src/Orb/Models/MatrixWithAllocationConfig.cs index 8d4887b55..1b8e5b987 100644 --- a/src/Orb/Models/MatrixWithAllocationConfig.cs +++ b/src/Orb/Models/MatrixWithAllocationConfig.cs @@ -96,8 +96,11 @@ public override void Validate() public MatrixWithAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithAllocationConfig(MatrixWithAllocationConfig matrixWithAllocationConfig) : base(matrixWithAllocationConfig) { } +#pragma warning restore CS8618 public MatrixWithAllocationConfig(IReadOnlyDictionary rawData) { @@ -183,10 +186,13 @@ public override void Validate() public MatrixWithAllocationConfigMatrixValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithAllocationConfigMatrixValue( MatrixWithAllocationConfigMatrixValue matrixWithAllocationConfigMatrixValue ) : base(matrixWithAllocationConfigMatrixValue) { } +#pragma warning restore CS8618 public MatrixWithAllocationConfigMatrixValue(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Maximum.cs b/src/Orb/Models/Maximum.cs index f60f5a592..f54c13be3 100644 --- a/src/Orb/Models/Maximum.cs +++ b/src/Orb/Models/Maximum.cs @@ -80,9 +80,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Maximum() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Maximum(Maximum maximum) : base(maximum) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Maximum(IReadOnlyDictionary rawData) @@ -173,8 +176,11 @@ public override void Validate() public MaximumFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaximumFilter(MaximumFilter maximumFilter) : base(maximumFilter) { } +#pragma warning restore CS8618 public MaximumFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MaximumInterval.cs b/src/Orb/Models/MaximumInterval.cs index 5b4c83052..d3586e542 100644 --- a/src/Orb/Models/MaximumInterval.cs +++ b/src/Orb/Models/MaximumInterval.cs @@ -108,8 +108,11 @@ public override void Validate() public MaximumInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaximumInterval(MaximumInterval maximumInterval) : base(maximumInterval) { } +#pragma warning restore CS8618 public MaximumInterval(IReadOnlyDictionary rawData) { @@ -200,8 +203,11 @@ public override void Validate() public MaximumIntervalFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaximumIntervalFilter(MaximumIntervalFilter maximumIntervalFilter) : base(maximumIntervalFilter) { } +#pragma warning restore CS8618 public MaximumIntervalFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Metrics/BillableMetric.cs b/src/Orb/Models/Metrics/BillableMetric.cs index ecd533368..488676987 100644 --- a/src/Orb/Models/Metrics/BillableMetric.cs +++ b/src/Orb/Models/Metrics/BillableMetric.cs @@ -108,8 +108,11 @@ public override void Validate() public BillableMetric() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillableMetric(BillableMetric billableMetric) : base(billableMetric) { } +#pragma warning restore CS8618 public BillableMetric(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Metrics/MetricListPageResponse.cs b/src/Orb/Models/Metrics/MetricListPageResponse.cs index 5e20d729f..2e5d21459 100644 --- a/src/Orb/Models/Metrics/MetricListPageResponse.cs +++ b/src/Orb/Models/Metrics/MetricListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public MetricListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricListPageResponse(MetricListPageResponse metricListPageResponse) : base(metricListPageResponse) { } +#pragma warning restore CS8618 public MetricListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Minimum.cs b/src/Orb/Models/Minimum.cs index cebe5c9e5..d7a0dd608 100644 --- a/src/Orb/Models/Minimum.cs +++ b/src/Orb/Models/Minimum.cs @@ -80,9 +80,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Minimum() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Minimum(Minimum minimum) : base(minimum) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Minimum(IReadOnlyDictionary rawData) @@ -173,8 +176,11 @@ public override void Validate() public MinimumFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumFilter(MinimumFilter minimumFilter) : base(minimumFilter) { } +#pragma warning restore CS8618 public MinimumFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MinimumInterval.cs b/src/Orb/Models/MinimumInterval.cs index 3cb6c2846..b8a135599 100644 --- a/src/Orb/Models/MinimumInterval.cs +++ b/src/Orb/Models/MinimumInterval.cs @@ -108,8 +108,11 @@ public override void Validate() public MinimumInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumInterval(MinimumInterval minimumInterval) : base(minimumInterval) { } +#pragma warning restore CS8618 public MinimumInterval(IReadOnlyDictionary rawData) { @@ -200,8 +203,11 @@ public override void Validate() public MinimumIntervalFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumIntervalFilter(MinimumIntervalFilter minimumIntervalFilter) : base(minimumIntervalFilter) { } +#pragma warning restore CS8618 public MinimumIntervalFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MonetaryAmountDiscountAdjustment.cs b/src/Orb/Models/MonetaryAmountDiscountAdjustment.cs index fb559b896..51a4f9bba 100644 --- a/src/Orb/Models/MonetaryAmountDiscountAdjustment.cs +++ b/src/Orb/Models/MonetaryAmountDiscountAdjustment.cs @@ -169,11 +169,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryAmountDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryAmountDiscountAdjustment( MonetaryAmountDiscountAdjustment monetaryAmountDiscountAdjustment ) : base(monetaryAmountDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryAmountDiscountAdjustment(IReadOnlyDictionary rawData) @@ -315,10 +318,13 @@ public override void Validate() public MonetaryAmountDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryAmountDiscountAdjustmentFilter( MonetaryAmountDiscountAdjustmentFilter monetaryAmountDiscountAdjustmentFilter ) : base(monetaryAmountDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryAmountDiscountAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MonetaryMaximumAdjustment.cs b/src/Orb/Models/MonetaryMaximumAdjustment.cs index 731f2bb04..270213cde 100644 --- a/src/Orb/Models/MonetaryMaximumAdjustment.cs +++ b/src/Orb/Models/MonetaryMaximumAdjustment.cs @@ -166,9 +166,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMaximumAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMaximumAdjustment(MonetaryMaximumAdjustment monetaryMaximumAdjustment) : base(monetaryMaximumAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMaximumAdjustment(IReadOnlyDictionary rawData) @@ -311,10 +314,13 @@ public override void Validate() public MonetaryMaximumAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryMaximumAdjustmentFilter( MonetaryMaximumAdjustmentFilter monetaryMaximumAdjustmentFilter ) : base(monetaryMaximumAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryMaximumAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MonetaryMinimumAdjustment.cs b/src/Orb/Models/MonetaryMinimumAdjustment.cs index 1c034f6fe..b3d0cd96f 100644 --- a/src/Orb/Models/MonetaryMinimumAdjustment.cs +++ b/src/Orb/Models/MonetaryMinimumAdjustment.cs @@ -180,9 +180,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMinimumAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMinimumAdjustment(MonetaryMinimumAdjustment monetaryMinimumAdjustment) : base(monetaryMinimumAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMinimumAdjustment(IReadOnlyDictionary rawData) @@ -325,10 +328,13 @@ public override void Validate() public MonetaryMinimumAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryMinimumAdjustmentFilter( MonetaryMinimumAdjustmentFilter monetaryMinimumAdjustmentFilter ) : base(monetaryMinimumAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryMinimumAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MonetaryPercentageDiscountAdjustment.cs b/src/Orb/Models/MonetaryPercentageDiscountAdjustment.cs index 129c3b351..ea6e1fe3a 100644 --- a/src/Orb/Models/MonetaryPercentageDiscountAdjustment.cs +++ b/src/Orb/Models/MonetaryPercentageDiscountAdjustment.cs @@ -172,11 +172,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryPercentageDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryPercentageDiscountAdjustment( MonetaryPercentageDiscountAdjustment monetaryPercentageDiscountAdjustment ) : base(monetaryPercentageDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryPercentageDiscountAdjustment(IReadOnlyDictionary rawData) @@ -322,10 +325,13 @@ public override void Validate() public MonetaryPercentageDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryPercentageDiscountAdjustmentFilter( MonetaryPercentageDiscountAdjustmentFilter monetaryPercentageDiscountAdjustmentFilter ) : base(monetaryPercentageDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryPercentageDiscountAdjustmentFilter( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/MonetaryUsageDiscountAdjustment.cs b/src/Orb/Models/MonetaryUsageDiscountAdjustment.cs index 77fe60fab..d59830656 100644 --- a/src/Orb/Models/MonetaryUsageDiscountAdjustment.cs +++ b/src/Orb/Models/MonetaryUsageDiscountAdjustment.cs @@ -169,11 +169,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryUsageDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryUsageDiscountAdjustment( MonetaryUsageDiscountAdjustment monetaryUsageDiscountAdjustment ) : base(monetaryUsageDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryUsageDiscountAdjustment(IReadOnlyDictionary rawData) @@ -316,10 +319,13 @@ public override void Validate() public MonetaryUsageDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryUsageDiscountAdjustmentFilter( MonetaryUsageDiscountAdjustmentFilter monetaryUsageDiscountAdjustmentFilter ) : base(monetaryUsageDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryUsageDiscountAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewAllocationPrice.cs b/src/Orb/Models/NewAllocationPrice.cs index c39dcb00a..24b7b3205 100644 --- a/src/Orb/Models/NewAllocationPrice.cs +++ b/src/Orb/Models/NewAllocationPrice.cs @@ -157,8 +157,11 @@ public override void Validate() public NewAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAllocationPrice(NewAllocationPrice newAllocationPrice) : base(newAllocationPrice) { } +#pragma warning restore CS8618 public NewAllocationPrice(IReadOnlyDictionary rawData) { @@ -308,8 +311,11 @@ public override void Validate() public NewAllocationPriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAllocationPriceFilter(NewAllocationPriceFilter newAllocationPriceFilter) : base(newAllocationPriceFilter) { } +#pragma warning restore CS8618 public NewAllocationPriceFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewAmountDiscount.cs b/src/Orb/Models/NewAmountDiscount.cs index 7a11b48b1..cde0bc3d4 100644 --- a/src/Orb/Models/NewAmountDiscount.cs +++ b/src/Orb/Models/NewAmountDiscount.cs @@ -174,8 +174,11 @@ public override void Validate() public NewAmountDiscount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAmountDiscount(NewAmountDiscount newAmountDiscount) : base(newAmountDiscount) { } +#pragma warning restore CS8618 public NewAmountDiscount(IReadOnlyDictionary rawData) { @@ -354,8 +357,11 @@ public override void Validate() public NewAmountDiscountFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAmountDiscountFilter(NewAmountDiscountFilter newAmountDiscountFilter) : base(newAmountDiscountFilter) { } +#pragma warning restore CS8618 public NewAmountDiscountFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewBillingCycleConfiguration.cs b/src/Orb/Models/NewBillingCycleConfiguration.cs index 32f837807..a4cf653f3 100644 --- a/src/Orb/Models/NewBillingCycleConfiguration.cs +++ b/src/Orb/Models/NewBillingCycleConfiguration.cs @@ -51,8 +51,11 @@ public override void Validate() public NewBillingCycleConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewBillingCycleConfiguration(NewBillingCycleConfiguration newBillingCycleConfiguration) : base(newBillingCycleConfiguration) { } +#pragma warning restore CS8618 public NewBillingCycleConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewDimensionalPriceConfiguration.cs b/src/Orb/Models/NewDimensionalPriceConfiguration.cs index 2d917ada7..ce052b21f 100644 --- a/src/Orb/Models/NewDimensionalPriceConfiguration.cs +++ b/src/Orb/Models/NewDimensionalPriceConfiguration.cs @@ -71,10 +71,13 @@ public override void Validate() public NewDimensionalPriceConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewDimensionalPriceConfiguration( NewDimensionalPriceConfiguration newDimensionalPriceConfiguration ) : base(newDimensionalPriceConfiguration) { } +#pragma warning restore CS8618 public NewDimensionalPriceConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingBulkPrice.cs b/src/Orb/Models/NewFloatingBulkPrice.cs index 2687a63e2..f1556201c 100644 --- a/src/Orb/Models/NewFloatingBulkPrice.cs +++ b/src/Orb/Models/NewFloatingBulkPrice.cs @@ -276,8 +276,11 @@ public override void Validate() public NewFloatingBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingBulkPrice(NewFloatingBulkPrice newFloatingBulkPrice) : base(newFloatingBulkPrice) { } +#pragma warning restore CS8618 public NewFloatingBulkPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs index 5fc419ee5..39538ca7e 100644 --- a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingBulkWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingBulkWithProrationPrice( NewFloatingBulkWithProrationPrice newFloatingBulkWithProrationPrice ) : base(newFloatingBulkWithProrationPrice) { } +#pragma warning restore CS8618 public NewFloatingBulkWithProrationPrice(IReadOnlyDictionary rawData) { @@ -359,8 +362,11 @@ public override void Validate() public BulkWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationConfig(BulkWithProrationConfig bulkWithProrationConfig) : base(bulkWithProrationConfig) { } +#pragma warning restore CS8618 public BulkWithProrationConfig(IReadOnlyDictionary rawData) { @@ -440,8 +446,11 @@ public override void Validate() public Tier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Tier(Tier tier) : base(tier) { } +#pragma warning restore CS8618 public Tier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs index 3f61fd5fc..a2833ffd9 100644 --- a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingCumulativeGroupedBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingCumulativeGroupedBulkPrice( NewFloatingCumulativeGroupedBulkPrice newFloatingCumulativeGroupedBulkPrice ) : base(newFloatingCumulativeGroupedBulkPrice) { } +#pragma warning restore CS8618 public NewFloatingCumulativeGroupedBulkPrice(IReadOnlyDictionary rawData) { @@ -435,8 +438,11 @@ public override void Validate() public CumulativeGroupedBulkConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedBulkConfig(CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig) : base(cumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkConfig(IReadOnlyDictionary rawData) { @@ -523,8 +529,11 @@ public override void Validate() public DimensionValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionValue(DimensionValue dimensionValue) : base(dimensionValue) { } +#pragma warning restore CS8618 public DimensionValue(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs index 46ff4e96f..bba677c43 100644 --- a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs @@ -287,10 +287,13 @@ public override void Validate() public NewFloatingGroupedAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedAllocationPrice( NewFloatingGroupedAllocationPrice newFloatingGroupedAllocationPrice ) : base(newFloatingGroupedAllocationPrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedAllocationPrice(IReadOnlyDictionary rawData) { @@ -437,8 +440,11 @@ public override void Validate() public GroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedAllocationConfig(GroupedAllocationConfig groupedAllocationConfig) : base(groupedAllocationConfig) { } +#pragma warning restore CS8618 public GroupedAllocationConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs index 8ff9423a6..5790f1150 100644 --- a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingGroupedTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedTieredPackagePrice( NewFloatingGroupedTieredPackagePrice newFloatingGroupedTieredPackagePrice ) : base(newFloatingGroupedTieredPackagePrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -450,8 +453,11 @@ public override void Validate() public GroupedTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageConfig(GroupedTieredPackageConfig groupedTieredPackageConfig) : base(groupedTieredPackageConfig) { } +#pragma warning restore CS8618 public GroupedTieredPackageConfig(IReadOnlyDictionary rawData) { @@ -526,10 +532,13 @@ public override void Validate() public GroupedTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageConfigTier( GroupedTieredPackageConfigTier groupedTieredPackageConfigTier ) : base(groupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredPackageConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs index fb2537ca4..31238c9f6 100644 --- a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs @@ -283,10 +283,13 @@ public override void Validate() public NewFloatingGroupedTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedTieredPrice( NewFloatingGroupedTieredPrice newFloatingGroupedTieredPrice ) : base(newFloatingGroupedTieredPrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedTieredPrice(IReadOnlyDictionary rawData) { @@ -428,8 +431,11 @@ public override void Validate() public GroupedTieredConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) : base(groupedTieredConfig) { } +#pragma warning restore CS8618 public GroupedTieredConfig(IReadOnlyDictionary rawData) { @@ -498,8 +504,11 @@ public override void Validate() public GroupedTieredConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) : base(groupedTieredConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs index 92cfa8ed4..364c281cf 100644 --- a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingGroupedWithMeteredMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedWithMeteredMinimumPrice( NewFloatingGroupedWithMeteredMinimumPrice newFloatingGroupedWithMeteredMinimumPrice ) : base(newFloatingGroupedWithMeteredMinimumPrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedWithMeteredMinimumPrice( IReadOnlyDictionary rawData @@ -508,10 +511,13 @@ public override void Validate() public GroupedWithMeteredMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumConfig( GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig ) : base(groupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumConfig(IReadOnlyDictionary rawData) { @@ -578,8 +584,11 @@ public override void Validate() public ScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalingFactor(ScalingFactor scalingFactor) : base(scalingFactor) { } +#pragma warning restore CS8618 public ScalingFactor(IReadOnlyDictionary rawData) { @@ -646,8 +655,11 @@ public override void Validate() public UnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitAmount(UnitAmount unitAmount) : base(unitAmount) { } +#pragma warning restore CS8618 public UnitAmount(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs index 2553b6a48..81c51bea7 100644 --- a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs @@ -287,10 +287,13 @@ public override void Validate() public NewFloatingGroupedWithProratedMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedWithProratedMinimumPrice( NewFloatingGroupedWithProratedMinimumPrice newFloatingGroupedWithProratedMinimumPrice ) : base(newFloatingGroupedWithProratedMinimumPrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedWithProratedMinimumPrice( IReadOnlyDictionary rawData @@ -445,10 +448,13 @@ public override void Validate() public GroupedWithProratedMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithProratedMinimumConfig( GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig ) : base(groupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithProratedMinimumConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingMatrixPrice.cs b/src/Orb/Models/NewFloatingMatrixPrice.cs index fd77ce172..a92a46f91 100644 --- a/src/Orb/Models/NewFloatingMatrixPrice.cs +++ b/src/Orb/Models/NewFloatingMatrixPrice.cs @@ -280,8 +280,11 @@ public override void Validate() public NewFloatingMatrixPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMatrixPrice(NewFloatingMatrixPrice newFloatingMatrixPrice) : base(newFloatingMatrixPrice) { } +#pragma warning restore CS8618 public NewFloatingMatrixPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs index 4e0dc6133..5bb1a68d0 100644 --- a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs @@ -287,10 +287,13 @@ public override void Validate() public NewFloatingMatrixWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMatrixWithAllocationPrice( NewFloatingMatrixWithAllocationPrice newFloatingMatrixWithAllocationPrice ) : base(newFloatingMatrixWithAllocationPrice) { } +#pragma warning restore CS8618 public NewFloatingMatrixWithAllocationPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs index 2551ddd29..cc6ccb604 100644 --- a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingMatrixWithDisplayNamePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMatrixWithDisplayNamePrice( NewFloatingMatrixWithDisplayNamePrice newFloatingMatrixWithDisplayNamePrice ) : base(newFloatingMatrixWithDisplayNamePrice) { } +#pragma warning restore CS8618 public NewFloatingMatrixWithDisplayNamePrice(IReadOnlyDictionary rawData) { @@ -438,8 +441,11 @@ public override void Validate() public MatrixWithDisplayNameConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameConfig(MatrixWithDisplayNameConfig matrixWithDisplayNameConfig) : base(matrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameConfig(IReadOnlyDictionary rawData) { @@ -531,10 +537,13 @@ public override void Validate() public MatrixWithDisplayNameConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameConfigUnitAmount( MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount ) : base(matrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameConfigUnitAmount(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs index 3632ec4db..cd56d95a7 100644 --- a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingMaxGroupTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMaxGroupTieredPackagePrice( NewFloatingMaxGroupTieredPackagePrice newFloatingMaxGroupTieredPackagePrice ) : base(newFloatingMaxGroupTieredPackagePrice) { } +#pragma warning restore CS8618 public NewFloatingMaxGroupTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -449,8 +452,11 @@ public override void Validate() public MaxGroupTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageConfig(MaxGroupTieredPackageConfig maxGroupTieredPackageConfig) : base(maxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageConfig(IReadOnlyDictionary rawData) { @@ -525,10 +531,13 @@ public override void Validate() public MaxGroupTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageConfigTier( MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier ) : base(maxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs index 669ffc562..d6881251e 100644 --- a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs +++ b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs @@ -287,10 +287,13 @@ public override void Validate() public NewFloatingMinimumCompositePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMinimumCompositePrice( NewFloatingMinimumCompositePrice newFloatingMinimumCompositePrice ) : base(newFloatingMinimumCompositePrice) { } +#pragma warning restore CS8618 public NewFloatingMinimumCompositePrice(IReadOnlyDictionary rawData) { @@ -431,8 +434,11 @@ public override void Validate() public MinimumCompositeConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumCompositeConfig(MinimumCompositeConfig minimumCompositeConfig) : base(minimumCompositeConfig) { } +#pragma warning restore CS8618 public MinimumCompositeConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingPackagePrice.cs b/src/Orb/Models/NewFloatingPackagePrice.cs index 2068ce0d5..90e5739f0 100644 --- a/src/Orb/Models/NewFloatingPackagePrice.cs +++ b/src/Orb/Models/NewFloatingPackagePrice.cs @@ -280,8 +280,11 @@ public override void Validate() public NewFloatingPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingPackagePrice(NewFloatingPackagePrice newFloatingPackagePrice) : base(newFloatingPackagePrice) { } +#pragma warning restore CS8618 public NewFloatingPackagePrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs index 6b8fea808..7ec08d46e 100644 --- a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs @@ -287,10 +287,13 @@ public override void Validate() public NewFloatingPackageWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingPackageWithAllocationPrice( NewFloatingPackageWithAllocationPrice newFloatingPackageWithAllocationPrice ) : base(newFloatingPackageWithAllocationPrice) { } +#pragma warning restore CS8618 public NewFloatingPackageWithAllocationPrice(IReadOnlyDictionary rawData) { @@ -478,8 +481,11 @@ public override void Validate() public PackageWithAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PackageWithAllocationConfig(PackageWithAllocationConfig packageWithAllocationConfig) : base(packageWithAllocationConfig) { } +#pragma warning restore CS8618 public PackageWithAllocationConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs index d3a79f6ab..14cc6f4ab 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs @@ -291,10 +291,13 @@ public override void Validate() public NewFloatingScalableMatrixWithTieredPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingScalableMatrixWithTieredPricingPrice( NewFloatingScalableMatrixWithTieredPricingPrice newFloatingScalableMatrixWithTieredPricingPrice ) : base(newFloatingScalableMatrixWithTieredPricingPrice) { } +#pragma warning restore CS8618 public NewFloatingScalableMatrixWithTieredPricingPrice( IReadOnlyDictionary rawData @@ -529,10 +532,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingConfig( ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig ) : base(scalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingConfig(IReadOnlyDictionary rawData) { @@ -611,8 +617,11 @@ public override void Validate() public MatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixScalingFactor(MatrixScalingFactor matrixScalingFactor) : base(matrixScalingFactor) { } +#pragma warning restore CS8618 public MatrixScalingFactor(IReadOnlyDictionary rawData) { @@ -683,10 +692,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingConfigTier( ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier ) : base(scalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs index f44f6d75d..b255c0f40 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs @@ -291,10 +291,13 @@ public override void Validate() public NewFloatingScalableMatrixWithUnitPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingScalableMatrixWithUnitPricingPrice( NewFloatingScalableMatrixWithUnitPricingPrice newFloatingScalableMatrixWithUnitPricingPrice ) : base(newFloatingScalableMatrixWithUnitPricingPrice) { } +#pragma warning restore CS8618 public NewFloatingScalableMatrixWithUnitPricingPrice( IReadOnlyDictionary rawData @@ -534,10 +537,13 @@ public override void Validate() public ScalableMatrixWithUnitPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingConfig( ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig ) : base(scalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingConfig(IReadOnlyDictionary rawData) { @@ -620,10 +626,13 @@ public override void Validate() public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor( ScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingConfigMatrixScalingFactor ) : base(scalableMatrixWithUnitPricingConfigMatrixScalingFactor) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs index 460aa1a06..349b4043e 100644 --- a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingThresholdTotalAmountPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingThresholdTotalAmountPrice( NewFloatingThresholdTotalAmountPrice newFloatingThresholdTotalAmountPrice ) : base(newFloatingThresholdTotalAmountPrice) { } +#pragma warning restore CS8618 public NewFloatingThresholdTotalAmountPrice(IReadOnlyDictionary rawData) { @@ -486,8 +489,11 @@ public override void Validate() public ThresholdTotalAmountConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ThresholdTotalAmountConfig(ThresholdTotalAmountConfig thresholdTotalAmountConfig) : base(thresholdTotalAmountConfig) { } +#pragma warning restore CS8618 public ThresholdTotalAmountConfig(IReadOnlyDictionary rawData) { @@ -564,8 +570,11 @@ public override void Validate() public ConsumptionTable() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ConsumptionTable(ConsumptionTable consumptionTable) : base(consumptionTable) { } +#pragma warning restore CS8618 public ConsumptionTable(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingTieredPackagePrice.cs b/src/Orb/Models/NewFloatingTieredPackagePrice.cs index c62715c8d..d01eec41f 100644 --- a/src/Orb/Models/NewFloatingTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingTieredPackagePrice.cs @@ -283,10 +283,13 @@ public override void Validate() public NewFloatingTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredPackagePrice( NewFloatingTieredPackagePrice newFloatingTieredPackagePrice ) : base(newFloatingTieredPackagePrice) { } +#pragma warning restore CS8618 public NewFloatingTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -473,8 +476,11 @@ public override void Validate() public TieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageConfig(TieredPackageConfig tieredPackageConfig) : base(tieredPackageConfig) { } +#pragma warning restore CS8618 public TieredPackageConfig(IReadOnlyDictionary rawData) { @@ -543,8 +549,11 @@ public override void Validate() public TieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageConfigTier(TieredPackageConfigTier tieredPackageConfigTier) : base(tieredPackageConfigTier) { } +#pragma warning restore CS8618 public TieredPackageConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs index b3b286c01..da3834a7d 100644 --- a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingTieredPackageWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredPackageWithMinimumPrice( NewFloatingTieredPackageWithMinimumPrice newFloatingTieredPackageWithMinimumPrice ) : base(newFloatingTieredPackageWithMinimumPrice) { } +#pragma warning restore CS8618 public NewFloatingTieredPackageWithMinimumPrice( IReadOnlyDictionary rawData @@ -488,10 +491,13 @@ public override void Validate() public TieredPackageWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumConfig( TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig ) : base(tieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumConfig(IReadOnlyDictionary rawData) { @@ -574,10 +580,13 @@ public override void Validate() public TieredPackageWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumConfigTier( TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier ) : base(tieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingTieredPrice.cs b/src/Orb/Models/NewFloatingTieredPrice.cs index cd30975f6..0f6926bb7 100644 --- a/src/Orb/Models/NewFloatingTieredPrice.cs +++ b/src/Orb/Models/NewFloatingTieredPrice.cs @@ -280,8 +280,11 @@ public override void Validate() public NewFloatingTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredPrice(NewFloatingTieredPrice newFloatingTieredPrice) : base(newFloatingTieredPrice) { } +#pragma warning restore CS8618 public NewFloatingTieredPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs index bf420bab6..1316ef516 100644 --- a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingTieredWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredWithMinimumPrice( NewFloatingTieredWithMinimumPrice newFloatingTieredWithMinimumPrice ) : base(newFloatingTieredWithMinimumPrice) { } +#pragma warning restore CS8618 public NewFloatingTieredWithMinimumPrice(IReadOnlyDictionary rawData) { @@ -512,8 +515,11 @@ public override void Validate() public TieredWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) : base(tieredWithMinimumConfig) { } +#pragma warning restore CS8618 public TieredWithMinimumConfig(IReadOnlyDictionary rawData) { @@ -603,8 +609,11 @@ public override void Validate() public TieredWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithMinimumConfigTier(TieredWithMinimumConfigTier tieredWithMinimumConfigTier) : base(tieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 public TieredWithMinimumConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs index 1b20ff274..2d7415f40 100644 --- a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs @@ -288,10 +288,13 @@ public override void Validate() public NewFloatingTieredWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredWithProrationPrice( NewFloatingTieredWithProrationPrice newFloatingTieredWithProrationPrice ) : base(newFloatingTieredWithProrationPrice) { } +#pragma warning restore CS8618 public NewFloatingTieredWithProrationPrice(IReadOnlyDictionary rawData) { @@ -471,8 +474,11 @@ public override void Validate() public TieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationConfig(IReadOnlyDictionary rawData) { @@ -554,10 +560,13 @@ public override void Validate() public TieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfigTier( TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingUnitPrice.cs b/src/Orb/Models/NewFloatingUnitPrice.cs index a682455b4..f9f356f27 100644 --- a/src/Orb/Models/NewFloatingUnitPrice.cs +++ b/src/Orb/Models/NewFloatingUnitPrice.cs @@ -280,8 +280,11 @@ public override void Validate() public NewFloatingUnitPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingUnitPrice(NewFloatingUnitPrice newFloatingUnitPrice) : base(newFloatingUnitPrice) { } +#pragma warning restore CS8618 public NewFloatingUnitPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs index c70ae8b52..19fe09d50 100644 --- a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs +++ b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs @@ -285,10 +285,13 @@ public override void Validate() public NewFloatingUnitWithPercentPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingUnitWithPercentPrice( NewFloatingUnitWithPercentPrice newFloatingUnitWithPercentPrice ) : base(newFloatingUnitWithPercentPrice) { } +#pragma warning restore CS8618 public NewFloatingUnitWithPercentPrice(IReadOnlyDictionary rawData) { @@ -466,8 +469,11 @@ public override void Validate() public UnitWithPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithPercentConfig(UnitWithPercentConfig unitWithPercentConfig) : base(unitWithPercentConfig) { } +#pragma warning restore CS8618 public UnitWithPercentConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs index 1e6e13504..712e77413 100644 --- a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs @@ -287,10 +287,13 @@ public override void Validate() public NewFloatingUnitWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingUnitWithProrationPrice( NewFloatingUnitWithProrationPrice newFloatingUnitWithProrationPrice ) : base(newFloatingUnitWithProrationPrice) { } +#pragma warning restore CS8618 public NewFloatingUnitWithProrationPrice(IReadOnlyDictionary rawData) { @@ -455,8 +458,11 @@ public override void Validate() public UnitWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithProrationConfig(UnitWithProrationConfig unitWithProrationConfig) : base(unitWithProrationConfig) { } +#pragma warning restore CS8618 public UnitWithProrationConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewMaximum.cs b/src/Orb/Models/NewMaximum.cs index b822d02da..b94fc1243 100644 --- a/src/Orb/Models/NewMaximum.cs +++ b/src/Orb/Models/NewMaximum.cs @@ -176,8 +176,11 @@ public override void Validate() public NewMaximum() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewMaximum(NewMaximum newMaximum) : base(newMaximum) { } +#pragma warning restore CS8618 public NewMaximum(IReadOnlyDictionary rawData) { @@ -351,8 +354,11 @@ public override void Validate() public NewMaximumFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewMaximumFilter(NewMaximumFilter newMaximumFilter) : base(newMaximumFilter) { } +#pragma warning restore CS8618 public NewMaximumFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewMinimum.cs b/src/Orb/Models/NewMinimum.cs index 1d06015b6..0aeb377ea 100644 --- a/src/Orb/Models/NewMinimum.cs +++ b/src/Orb/Models/NewMinimum.cs @@ -190,8 +190,11 @@ public override void Validate() public NewMinimum() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewMinimum(NewMinimum newMinimum) : base(newMinimum) { } +#pragma warning restore CS8618 public NewMinimum(IReadOnlyDictionary rawData) { @@ -365,8 +368,11 @@ public override void Validate() public NewMinimumFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewMinimumFilter(NewMinimumFilter newMinimumFilter) : base(newMinimumFilter) { } +#pragma warning restore CS8618 public NewMinimumFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewPercentageDiscount.cs b/src/Orb/Models/NewPercentageDiscount.cs index 0b7c4131e..c03ed82ba 100644 --- a/src/Orb/Models/NewPercentageDiscount.cs +++ b/src/Orb/Models/NewPercentageDiscount.cs @@ -178,8 +178,11 @@ public override void Validate() public NewPercentageDiscount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPercentageDiscount(NewPercentageDiscount newPercentageDiscount) : base(newPercentageDiscount) { } +#pragma warning restore CS8618 public NewPercentageDiscount(IReadOnlyDictionary rawData) { @@ -362,8 +365,11 @@ public override void Validate() public NewPercentageDiscountFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPercentageDiscountFilter(NewPercentageDiscountFilter newPercentageDiscountFilter) : base(newPercentageDiscountFilter) { } +#pragma warning restore CS8618 public NewPercentageDiscountFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewPlanBulkPrice.cs b/src/Orb/Models/NewPlanBulkPrice.cs index d18950b20..d9ea64713 100644 --- a/src/Orb/Models/NewPlanBulkPrice.cs +++ b/src/Orb/Models/NewPlanBulkPrice.cs @@ -296,8 +296,11 @@ public override void Validate() public NewPlanBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanBulkPrice(NewPlanBulkPrice newPlanBulkPrice) : base(newPlanBulkPrice) { } +#pragma warning restore CS8618 public NewPlanBulkPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs index cb43ff72a..a4b4bb670 100644 --- a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs +++ b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs @@ -301,10 +301,13 @@ public override void Validate() public NewPlanBulkWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanBulkWithProrationPrice( NewPlanBulkWithProrationPrice newPlanBulkWithProrationPrice ) : base(newPlanBulkWithProrationPrice) { } +#pragma warning restore CS8618 public NewPlanBulkWithProrationPrice(IReadOnlyDictionary rawData) { @@ -378,10 +381,13 @@ public override void Validate() public NewPlanBulkWithProrationPriceBulkWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanBulkWithProrationPriceBulkWithProrationConfig( NewPlanBulkWithProrationPriceBulkWithProrationConfig newPlanBulkWithProrationPriceBulkWithProrationConfig ) : base(newPlanBulkWithProrationPriceBulkWithProrationConfig) { } +#pragma warning restore CS8618 public NewPlanBulkWithProrationPriceBulkWithProrationConfig( IReadOnlyDictionary rawData @@ -473,10 +479,13 @@ public override void Validate() public NewPlanBulkWithProrationPriceBulkWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanBulkWithProrationPriceBulkWithProrationConfigTier( NewPlanBulkWithProrationPriceBulkWithProrationConfigTier newPlanBulkWithProrationPriceBulkWithProrationConfigTier ) : base(newPlanBulkWithProrationPriceBulkWithProrationConfigTier) { } +#pragma warning restore CS8618 public NewPlanBulkWithProrationPriceBulkWithProrationConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs index 31e8ea177..4c29be8be 100644 --- a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanCumulativeGroupedBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanCumulativeGroupedBulkPrice( NewPlanCumulativeGroupedBulkPrice newPlanCumulativeGroupedBulkPrice ) : base(newPlanCumulativeGroupedBulkPrice) { } +#pragma warning restore CS8618 public NewPlanCumulativeGroupedBulkPrice(IReadOnlyDictionary rawData) { @@ -452,10 +455,13 @@ public override void Validate() public NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfig( NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfig newPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfig ) : base(newPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 public NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfig( IReadOnlyDictionary rawData @@ -553,10 +559,13 @@ public override void Validate() public NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValue( NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValue newPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValue ) : base(newPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValue) { } +#pragma warning restore CS8618 public NewPlanCumulativeGroupedBulkPriceCumulativeGroupedBulkConfigDimensionValue( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs index d35081227..3e8af7268 100644 --- a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs +++ b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs @@ -300,10 +300,13 @@ public override void Validate() public NewPlanGroupedAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedAllocationPrice( NewPlanGroupedAllocationPrice newPlanGroupedAllocationPrice ) : base(newPlanGroupedAllocationPrice) { } +#pragma warning restore CS8618 public NewPlanGroupedAllocationPrice(IReadOnlyDictionary rawData) { @@ -455,10 +458,13 @@ public override void Validate() public NewPlanGroupedAllocationPriceGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedAllocationPriceGroupedAllocationConfig( NewPlanGroupedAllocationPriceGroupedAllocationConfig newPlanGroupedAllocationPriceGroupedAllocationConfig ) : base(newPlanGroupedAllocationPriceGroupedAllocationConfig) { } +#pragma warning restore CS8618 public NewPlanGroupedAllocationPriceGroupedAllocationConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs index be0dd80d3..32cc6fa5f 100644 --- a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanGroupedTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedTieredPackagePrice( NewPlanGroupedTieredPackagePrice newPlanGroupedTieredPackagePrice ) : base(newPlanGroupedTieredPackagePrice) { } +#pragma warning restore CS8618 public NewPlanGroupedTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -467,10 +470,13 @@ public override void Validate() public NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfig( NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfig newPlanGroupedTieredPackagePriceGroupedTieredPackageConfig ) : base(newPlanGroupedTieredPackagePriceGroupedTieredPackageConfig) { } +#pragma warning restore CS8618 public NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfig( IReadOnlyDictionary rawData @@ -551,10 +557,13 @@ public override void Validate() public NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTier( NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTier newPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTier ) : base(newPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 public NewPlanGroupedTieredPackagePriceGroupedTieredPackageConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanGroupedTieredPrice.cs b/src/Orb/Models/NewPlanGroupedTieredPrice.cs index 3db6af5e1..04e9f9e2f 100644 --- a/src/Orb/Models/NewPlanGroupedTieredPrice.cs +++ b/src/Orb/Models/NewPlanGroupedTieredPrice.cs @@ -301,8 +301,11 @@ public override void Validate() public NewPlanGroupedTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedTieredPrice(NewPlanGroupedTieredPrice newPlanGroupedTieredPrice) : base(newPlanGroupedTieredPrice) { } +#pragma warning restore CS8618 public NewPlanGroupedTieredPrice(IReadOnlyDictionary rawData) { @@ -451,10 +454,13 @@ public override void Validate() public NewPlanGroupedTieredPriceGroupedTieredConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedTieredPriceGroupedTieredConfig( NewPlanGroupedTieredPriceGroupedTieredConfig newPlanGroupedTieredPriceGroupedTieredConfig ) : base(newPlanGroupedTieredPriceGroupedTieredConfig) { } +#pragma warning restore CS8618 public NewPlanGroupedTieredPriceGroupedTieredConfig( IReadOnlyDictionary rawData @@ -532,10 +538,13 @@ public override void Validate() public NewPlanGroupedTieredPriceGroupedTieredConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedTieredPriceGroupedTieredConfigTier( NewPlanGroupedTieredPriceGroupedTieredConfigTier newPlanGroupedTieredPriceGroupedTieredConfigTier ) : base(newPlanGroupedTieredPriceGroupedTieredConfigTier) { } +#pragma warning restore CS8618 public NewPlanGroupedTieredPriceGroupedTieredConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs index c6918497f..ef54d0616 100644 --- a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanGroupedWithMeteredMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedWithMeteredMinimumPrice( NewPlanGroupedWithMeteredMinimumPrice newPlanGroupedWithMeteredMinimumPrice ) : base(newPlanGroupedWithMeteredMinimumPrice) { } +#pragma warning restore CS8618 public NewPlanGroupedWithMeteredMinimumPrice(IReadOnlyDictionary rawData) { @@ -525,10 +528,13 @@ public override void Validate() public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfig( NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfig newPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfig ) : base(newPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfig( IReadOnlyDictionary rawData @@ -609,11 +615,14 @@ public override void Validate() public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactor( NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactor newPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactor ) : base(newPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactor) { } +#pragma warning restore CS8618 public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigScalingFactor( IReadOnlyDictionary rawData @@ -697,10 +706,13 @@ public override void Validate() public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmount( NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmount newPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmount ) : base(newPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmount) { } +#pragma warning restore CS8618 public NewPlanGroupedWithMeteredMinimumPriceGroupedWithMeteredMinimumConfigUnitAmount( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs index 9ba2bc2da..9d7e4ae9a 100644 --- a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs @@ -303,10 +303,13 @@ public override void Validate() public NewPlanGroupedWithProratedMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedWithProratedMinimumPrice( NewPlanGroupedWithProratedMinimumPrice newPlanGroupedWithProratedMinimumPrice ) : base(newPlanGroupedWithProratedMinimumPrice) { } +#pragma warning restore CS8618 public NewPlanGroupedWithProratedMinimumPrice(IReadOnlyDictionary rawData) { @@ -460,10 +463,13 @@ public override void Validate() public NewPlanGroupedWithProratedMinimumPriceGroupedWithProratedMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedWithProratedMinimumPriceGroupedWithProratedMinimumConfig( NewPlanGroupedWithProratedMinimumPriceGroupedWithProratedMinimumConfig newPlanGroupedWithProratedMinimumPriceGroupedWithProratedMinimumConfig ) : base(newPlanGroupedWithProratedMinimumPriceGroupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 public NewPlanGroupedWithProratedMinimumPriceGroupedWithProratedMinimumConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanMatrixPrice.cs b/src/Orb/Models/NewPlanMatrixPrice.cs index 2c6adbee7..e4a796c06 100644 --- a/src/Orb/Models/NewPlanMatrixPrice.cs +++ b/src/Orb/Models/NewPlanMatrixPrice.cs @@ -296,8 +296,11 @@ public override void Validate() public NewPlanMatrixPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMatrixPrice(NewPlanMatrixPrice newPlanMatrixPrice) : base(newPlanMatrixPrice) { } +#pragma warning restore CS8618 public NewPlanMatrixPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs index bd0f72c43..01ef02e75 100644 --- a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs @@ -303,10 +303,13 @@ public override void Validate() public NewPlanMatrixWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMatrixWithAllocationPrice( NewPlanMatrixWithAllocationPrice newPlanMatrixWithAllocationPrice ) : base(newPlanMatrixWithAllocationPrice) { } +#pragma warning restore CS8618 public NewPlanMatrixWithAllocationPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs index b399edc20..6d776c94b 100644 --- a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanMatrixWithDisplayNamePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMatrixWithDisplayNamePrice( NewPlanMatrixWithDisplayNamePrice newPlanMatrixWithDisplayNamePrice ) : base(newPlanMatrixWithDisplayNamePrice) { } +#pragma warning restore CS8618 public NewPlanMatrixWithDisplayNamePrice(IReadOnlyDictionary rawData) { @@ -455,10 +458,13 @@ public override void Validate() public NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfig( NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfig newPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfig ) : base(newPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 public NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfig( IReadOnlyDictionary rawData @@ -556,10 +562,13 @@ public override void Validate() public NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmount( NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmount newPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmount ) : base(newPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 public NewPlanMatrixWithDisplayNamePriceMatrixWithDisplayNameConfigUnitAmount( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs index f67602ebf..277f700bd 100644 --- a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanMaxGroupTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMaxGroupTieredPackagePrice( NewPlanMaxGroupTieredPackagePrice newPlanMaxGroupTieredPackagePrice ) : base(newPlanMaxGroupTieredPackagePrice) { } +#pragma warning restore CS8618 public NewPlanMaxGroupTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -466,10 +469,13 @@ public override void Validate() public NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfig( NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfig newPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfig ) : base(newPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 public NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfig( IReadOnlyDictionary rawData @@ -550,10 +556,13 @@ public override void Validate() public NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTier( NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTier newPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTier ) : base(newPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 public NewPlanMaxGroupTieredPackagePriceMaxGroupTieredPackageConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanMinimumCompositePrice.cs b/src/Orb/Models/NewPlanMinimumCompositePrice.cs index 75f339dea..7ac355c92 100644 --- a/src/Orb/Models/NewPlanMinimumCompositePrice.cs +++ b/src/Orb/Models/NewPlanMinimumCompositePrice.cs @@ -300,8 +300,11 @@ public override void Validate() public NewPlanMinimumCompositePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMinimumCompositePrice(NewPlanMinimumCompositePrice newPlanMinimumCompositePrice) : base(newPlanMinimumCompositePrice) { } +#pragma warning restore CS8618 public NewPlanMinimumCompositePrice(IReadOnlyDictionary rawData) { @@ -447,10 +450,13 @@ public override void Validate() public NewPlanMinimumCompositePriceMinimumCompositeConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMinimumCompositePriceMinimumCompositeConfig( NewPlanMinimumCompositePriceMinimumCompositeConfig newPlanMinimumCompositePriceMinimumCompositeConfig ) : base(newPlanMinimumCompositePriceMinimumCompositeConfig) { } +#pragma warning restore CS8618 public NewPlanMinimumCompositePriceMinimumCompositeConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanPackagePrice.cs b/src/Orb/Models/NewPlanPackagePrice.cs index f0ff05d76..f19b737dc 100644 --- a/src/Orb/Models/NewPlanPackagePrice.cs +++ b/src/Orb/Models/NewPlanPackagePrice.cs @@ -296,8 +296,11 @@ public override void Validate() public NewPlanPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanPackagePrice(NewPlanPackagePrice newPlanPackagePrice) : base(newPlanPackagePrice) { } +#pragma warning restore CS8618 public NewPlanPackagePrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs index b5c7793dd..8edefd077 100644 --- a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs +++ b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs @@ -303,10 +303,13 @@ public override void Validate() public NewPlanPackageWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanPackageWithAllocationPrice( NewPlanPackageWithAllocationPrice newPlanPackageWithAllocationPrice ) : base(newPlanPackageWithAllocationPrice) { } +#pragma warning restore CS8618 public NewPlanPackageWithAllocationPrice(IReadOnlyDictionary rawData) { @@ -496,10 +499,13 @@ public override void Validate() public NewPlanPackageWithAllocationPricePackageWithAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanPackageWithAllocationPricePackageWithAllocationConfig( NewPlanPackageWithAllocationPricePackageWithAllocationConfig newPlanPackageWithAllocationPricePackageWithAllocationConfig ) : base(newPlanPackageWithAllocationPricePackageWithAllocationConfig) { } +#pragma warning restore CS8618 public NewPlanPackageWithAllocationPricePackageWithAllocationConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs index 706da7ca1..85a5083ba 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanScalableMatrixWithTieredPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithTieredPricingPrice( NewPlanScalableMatrixWithTieredPricingPrice newPlanScalableMatrixWithTieredPricingPrice ) : base(newPlanScalableMatrixWithTieredPricingPrice) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithTieredPricingPrice( IReadOnlyDictionary rawData @@ -541,10 +544,13 @@ public override void Validate() public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfig( NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfig newPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfig ) : base(newPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfig( IReadOnlyDictionary rawData @@ -637,12 +643,15 @@ public override void Validate() public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactor( NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactor newPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactor ) : base( newPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactor ) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData @@ -724,11 +733,14 @@ public override void Validate() public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTier( NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTier newPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTier ) : base(newPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithTieredPricingPriceScalableMatrixWithTieredPricingConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs index b04312f7c..18f3f4163 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanScalableMatrixWithUnitPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithUnitPricingPrice( NewPlanScalableMatrixWithUnitPricingPrice newPlanScalableMatrixWithUnitPricingPrice ) : base(newPlanScalableMatrixWithUnitPricingPrice) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithUnitPricingPrice( IReadOnlyDictionary rawData @@ -548,10 +551,13 @@ public override void Validate() public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig( NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig newPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig ) : base(newPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig( IReadOnlyDictionary rawData @@ -644,12 +650,15 @@ public override void Validate() public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactor( NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactor newPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactor ) : base( newPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactor ) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs index 81d882f08..a915628a1 100644 --- a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanThresholdTotalAmountPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanThresholdTotalAmountPrice( NewPlanThresholdTotalAmountPrice newPlanThresholdTotalAmountPrice ) : base(newPlanThresholdTotalAmountPrice) { } +#pragma warning restore CS8618 public NewPlanThresholdTotalAmountPrice(IReadOnlyDictionary rawData) { @@ -503,10 +506,13 @@ public override void Validate() public NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfig( NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfig newPlanThresholdTotalAmountPriceThresholdTotalAmountConfig ) : base(newPlanThresholdTotalAmountPriceThresholdTotalAmountConfig) { } +#pragma warning restore CS8618 public NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfig( IReadOnlyDictionary rawData @@ -596,10 +602,13 @@ public override void Validate() public NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTable() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTable( NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTable newPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTable ) : base(newPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTable) { } +#pragma warning restore CS8618 public NewPlanThresholdTotalAmountPriceThresholdTotalAmountConfigConsumptionTable( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanTieredPackagePrice.cs b/src/Orb/Models/NewPlanTieredPackagePrice.cs index 85d60c7c5..05c53e2a4 100644 --- a/src/Orb/Models/NewPlanTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanTieredPackagePrice.cs @@ -301,8 +301,11 @@ public override void Validate() public NewPlanTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPackagePrice(NewPlanTieredPackagePrice newPlanTieredPackagePrice) : base(newPlanTieredPackagePrice) { } +#pragma warning restore CS8618 public NewPlanTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -496,10 +499,13 @@ public override void Validate() public NewPlanTieredPackagePriceTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPackagePriceTieredPackageConfig( NewPlanTieredPackagePriceTieredPackageConfig newPlanTieredPackagePriceTieredPackageConfig ) : base(newPlanTieredPackagePriceTieredPackageConfig) { } +#pragma warning restore CS8618 public NewPlanTieredPackagePriceTieredPackageConfig( IReadOnlyDictionary rawData @@ -577,10 +583,13 @@ public override void Validate() public NewPlanTieredPackagePriceTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPackagePriceTieredPackageConfigTier( NewPlanTieredPackagePriceTieredPackageConfigTier newPlanTieredPackagePriceTieredPackageConfigTier ) : base(newPlanTieredPackagePriceTieredPackageConfigTier) { } +#pragma warning restore CS8618 public NewPlanTieredPackagePriceTieredPackageConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs index b17f910c3..847caaeca 100644 --- a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewPlanTieredPackageWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPackageWithMinimumPrice( NewPlanTieredPackageWithMinimumPrice newPlanTieredPackageWithMinimumPrice ) : base(newPlanTieredPackageWithMinimumPrice) { } +#pragma warning restore CS8618 public NewPlanTieredPackageWithMinimumPrice(IReadOnlyDictionary rawData) { @@ -502,10 +505,13 @@ public override void Validate() public NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfig( NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfig newPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfig ) : base(newPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 public NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfig( IReadOnlyDictionary rawData @@ -597,10 +603,13 @@ public override void Validate() public NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTier( NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTier newPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTier ) : base(newPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 public NewPlanTieredPackageWithMinimumPriceTieredPackageWithMinimumConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanTieredPrice.cs b/src/Orb/Models/NewPlanTieredPrice.cs index 6239140f3..377e0a01f 100644 --- a/src/Orb/Models/NewPlanTieredPrice.cs +++ b/src/Orb/Models/NewPlanTieredPrice.cs @@ -296,8 +296,11 @@ public override void Validate() public NewPlanTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPrice(NewPlanTieredPrice newPlanTieredPrice) : base(newPlanTieredPrice) { } +#pragma warning restore CS8618 public NewPlanTieredPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs index 4228c73c2..499064eb6 100644 --- a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs +++ b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs @@ -301,10 +301,13 @@ public override void Validate() public NewPlanTieredWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredWithMinimumPrice( NewPlanTieredWithMinimumPrice newPlanTieredWithMinimumPrice ) : base(newPlanTieredWithMinimumPrice) { } +#pragma warning restore CS8618 public NewPlanTieredWithMinimumPrice(IReadOnlyDictionary rawData) { @@ -528,10 +531,13 @@ public override void Validate() public NewPlanTieredWithMinimumPriceTieredWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredWithMinimumPriceTieredWithMinimumConfig( NewPlanTieredWithMinimumPriceTieredWithMinimumConfig newPlanTieredWithMinimumPriceTieredWithMinimumConfig ) : base(newPlanTieredWithMinimumPriceTieredWithMinimumConfig) { } +#pragma warning restore CS8618 public NewPlanTieredWithMinimumPriceTieredWithMinimumConfig( IReadOnlyDictionary rawData @@ -631,10 +637,13 @@ public override void Validate() public NewPlanTieredWithMinimumPriceTieredWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredWithMinimumPriceTieredWithMinimumConfigTier( NewPlanTieredWithMinimumPriceTieredWithMinimumConfigTier newPlanTieredWithMinimumPriceTieredWithMinimumConfigTier ) : base(newPlanTieredWithMinimumPriceTieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 public NewPlanTieredWithMinimumPriceTieredWithMinimumConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanUnitPrice.cs b/src/Orb/Models/NewPlanUnitPrice.cs index 3f2ea1262..bdba6ab25 100644 --- a/src/Orb/Models/NewPlanUnitPrice.cs +++ b/src/Orb/Models/NewPlanUnitPrice.cs @@ -296,8 +296,11 @@ public override void Validate() public NewPlanUnitPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanUnitPrice(NewPlanUnitPrice newPlanUnitPrice) : base(newPlanUnitPrice) { } +#pragma warning restore CS8618 public NewPlanUnitPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs index 6c235d3e5..7640eaaa5 100644 --- a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs +++ b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs @@ -300,8 +300,11 @@ public override void Validate() public NewPlanUnitWithPercentPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanUnitWithPercentPrice(NewPlanUnitWithPercentPrice newPlanUnitWithPercentPrice) : base(newPlanUnitWithPercentPrice) { } +#pragma warning restore CS8618 public NewPlanUnitWithPercentPrice(IReadOnlyDictionary rawData) { @@ -484,10 +487,13 @@ public override void Validate() public NewPlanUnitWithPercentPriceUnitWithPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanUnitWithPercentPriceUnitWithPercentConfig( NewPlanUnitWithPercentPriceUnitWithPercentConfig newPlanUnitWithPercentPriceUnitWithPercentConfig ) : base(newPlanUnitWithPercentPriceUnitWithPercentConfig) { } +#pragma warning restore CS8618 public NewPlanUnitWithPercentPriceUnitWithPercentConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs index e830a05e9..156e087aa 100644 --- a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs +++ b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs @@ -300,10 +300,13 @@ public override void Validate() public NewPlanUnitWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanUnitWithProrationPrice( NewPlanUnitWithProrationPrice newPlanUnitWithProrationPrice ) : base(newPlanUnitWithProrationPrice) { } +#pragma warning restore CS8618 public NewPlanUnitWithProrationPrice(IReadOnlyDictionary rawData) { @@ -472,10 +475,13 @@ public override void Validate() public NewPlanUnitWithProrationPriceUnitWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanUnitWithProrationPriceUnitWithProrationConfig( NewPlanUnitWithProrationPriceUnitWithProrationConfig newPlanUnitWithProrationPriceUnitWithProrationConfig ) : base(newPlanUnitWithProrationPriceUnitWithProrationConfig) { } +#pragma warning restore CS8618 public NewPlanUnitWithProrationPriceUnitWithProrationConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/NewUsageDiscount.cs b/src/Orb/Models/NewUsageDiscount.cs index 7e3fb46c6..ce0ce0bf6 100644 --- a/src/Orb/Models/NewUsageDiscount.cs +++ b/src/Orb/Models/NewUsageDiscount.cs @@ -178,8 +178,11 @@ public override void Validate() public NewUsageDiscount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewUsageDiscount(NewUsageDiscount newUsageDiscount) : base(newUsageDiscount) { } +#pragma warning restore CS8618 public NewUsageDiscount(IReadOnlyDictionary rawData) { @@ -357,8 +360,11 @@ public override void Validate() public NewUsageDiscountFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewUsageDiscountFilter(NewUsageDiscountFilter newUsageDiscountFilter) : base(newUsageDiscountFilter) { } +#pragma warning restore CS8618 public NewUsageDiscountFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/OtherSubLineItem.cs b/src/Orb/Models/OtherSubLineItem.cs index e83f6ce39..1a8c2a83e 100644 --- a/src/Orb/Models/OtherSubLineItem.cs +++ b/src/Orb/Models/OtherSubLineItem.cs @@ -77,8 +77,11 @@ public override void Validate() public OtherSubLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public OtherSubLineItem(OtherSubLineItem otherSubLineItem) : base(otherSubLineItem) { } +#pragma warning restore CS8618 public OtherSubLineItem(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PackageConfig.cs b/src/Orb/Models/PackageConfig.cs index c54c56b5f..4641b4b9d 100644 --- a/src/Orb/Models/PackageConfig.cs +++ b/src/Orb/Models/PackageConfig.cs @@ -49,8 +49,11 @@ public override void Validate() public PackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PackageConfig(PackageConfig packageConfig) : base(packageConfig) { } +#pragma warning restore CS8618 public PackageConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PaginationMetadata.cs b/src/Orb/Models/PaginationMetadata.cs index 0c2fa298f..d1b003f75 100644 --- a/src/Orb/Models/PaginationMetadata.cs +++ b/src/Orb/Models/PaginationMetadata.cs @@ -39,8 +39,11 @@ public override void Validate() public PaginationMetadata() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PaginationMetadata(PaginationMetadata paginationMetadata) : base(paginationMetadata) { } +#pragma warning restore CS8618 public PaginationMetadata(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PerPriceCost.cs b/src/Orb/Models/PerPriceCost.cs index 5478e743f..3fdbfbb03 100644 --- a/src/Orb/Models/PerPriceCost.cs +++ b/src/Orb/Models/PerPriceCost.cs @@ -87,8 +87,11 @@ public override void Validate() public PerPriceCost() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PerPriceCost(PerPriceCost perPriceCost) : base(perPriceCost) { } +#pragma warning restore CS8618 public PerPriceCost(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PercentageDiscount.cs b/src/Orb/Models/PercentageDiscount.cs index cec3131f2..8f111ca84 100644 --- a/src/Orb/Models/PercentageDiscount.cs +++ b/src/Orb/Models/PercentageDiscount.cs @@ -105,8 +105,11 @@ public override void Validate() public PercentageDiscount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentageDiscount(PercentageDiscount percentageDiscount) : base(percentageDiscount) { } +#pragma warning restore CS8618 public PercentageDiscount(IReadOnlyDictionary rawData) { @@ -242,8 +245,11 @@ public override void Validate() public PercentageDiscountFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentageDiscountFilter(PercentageDiscountFilter percentageDiscountFilter) : base(percentageDiscountFilter) { } +#pragma warning restore CS8618 public PercentageDiscountFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PercentageDiscountInterval.cs b/src/Orb/Models/PercentageDiscountInterval.cs index 184fc602c..667bcb451 100644 --- a/src/Orb/Models/PercentageDiscountInterval.cs +++ b/src/Orb/Models/PercentageDiscountInterval.cs @@ -125,8 +125,11 @@ public override void Validate() public PercentageDiscountInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentageDiscountInterval(PercentageDiscountInterval percentageDiscountInterval) : base(percentageDiscountInterval) { } +#pragma warning restore CS8618 public PercentageDiscountInterval(IReadOnlyDictionary rawData) { @@ -267,10 +270,13 @@ public override void Validate() public PercentageDiscountIntervalFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentageDiscountIntervalFilter( PercentageDiscountIntervalFilter percentageDiscountIntervalFilter ) : base(percentageDiscountIntervalFilter) { } +#pragma warning restore CS8618 public PercentageDiscountIntervalFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PlanPhaseAmountDiscountAdjustment.cs b/src/Orb/Models/PlanPhaseAmountDiscountAdjustment.cs index fe80dd106..b1d5a39d0 100644 --- a/src/Orb/Models/PlanPhaseAmountDiscountAdjustment.cs +++ b/src/Orb/Models/PlanPhaseAmountDiscountAdjustment.cs @@ -169,11 +169,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseAmountDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseAmountDiscountAdjustment( PlanPhaseAmountDiscountAdjustment planPhaseAmountDiscountAdjustment ) : base(planPhaseAmountDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseAmountDiscountAdjustment(IReadOnlyDictionary rawData) @@ -316,10 +319,13 @@ public override void Validate() public PlanPhaseAmountDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanPhaseAmountDiscountAdjustmentFilter( PlanPhaseAmountDiscountAdjustmentFilter planPhaseAmountDiscountAdjustmentFilter ) : base(planPhaseAmountDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public PlanPhaseAmountDiscountAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PlanPhaseMaximumAdjustment.cs b/src/Orb/Models/PlanPhaseMaximumAdjustment.cs index 2a71f0031..8c370cdef 100644 --- a/src/Orb/Models/PlanPhaseMaximumAdjustment.cs +++ b/src/Orb/Models/PlanPhaseMaximumAdjustment.cs @@ -166,9 +166,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseMaximumAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseMaximumAdjustment(PlanPhaseMaximumAdjustment planPhaseMaximumAdjustment) : base(planPhaseMaximumAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseMaximumAdjustment(IReadOnlyDictionary rawData) @@ -311,10 +314,13 @@ public override void Validate() public PlanPhaseMaximumAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanPhaseMaximumAdjustmentFilter( PlanPhaseMaximumAdjustmentFilter planPhaseMaximumAdjustmentFilter ) : base(planPhaseMaximumAdjustmentFilter) { } +#pragma warning restore CS8618 public PlanPhaseMaximumAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PlanPhaseMinimumAdjustment.cs b/src/Orb/Models/PlanPhaseMinimumAdjustment.cs index 6e76bce94..4f88da536 100644 --- a/src/Orb/Models/PlanPhaseMinimumAdjustment.cs +++ b/src/Orb/Models/PlanPhaseMinimumAdjustment.cs @@ -180,9 +180,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseMinimumAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseMinimumAdjustment(PlanPhaseMinimumAdjustment planPhaseMinimumAdjustment) : base(planPhaseMinimumAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseMinimumAdjustment(IReadOnlyDictionary rawData) @@ -325,10 +328,13 @@ public override void Validate() public PlanPhaseMinimumAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanPhaseMinimumAdjustmentFilter( PlanPhaseMinimumAdjustmentFilter planPhaseMinimumAdjustmentFilter ) : base(planPhaseMinimumAdjustmentFilter) { } +#pragma warning restore CS8618 public PlanPhaseMinimumAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PlanPhasePercentageDiscountAdjustment.cs b/src/Orb/Models/PlanPhasePercentageDiscountAdjustment.cs index f68730f7b..3164b1470 100644 --- a/src/Orb/Models/PlanPhasePercentageDiscountAdjustment.cs +++ b/src/Orb/Models/PlanPhasePercentageDiscountAdjustment.cs @@ -172,11 +172,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhasePercentageDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhasePercentageDiscountAdjustment( PlanPhasePercentageDiscountAdjustment planPhasePercentageDiscountAdjustment ) : base(planPhasePercentageDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhasePercentageDiscountAdjustment(IReadOnlyDictionary rawData) @@ -322,10 +325,13 @@ public override void Validate() public PlanPhasePercentageDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanPhasePercentageDiscountAdjustmentFilter( PlanPhasePercentageDiscountAdjustmentFilter planPhasePercentageDiscountAdjustmentFilter ) : base(planPhasePercentageDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public PlanPhasePercentageDiscountAdjustmentFilter( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/PlanPhaseUsageDiscountAdjustment.cs b/src/Orb/Models/PlanPhaseUsageDiscountAdjustment.cs index c2847d78f..276b452b2 100644 --- a/src/Orb/Models/PlanPhaseUsageDiscountAdjustment.cs +++ b/src/Orb/Models/PlanPhaseUsageDiscountAdjustment.cs @@ -169,11 +169,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseUsageDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseUsageDiscountAdjustment( PlanPhaseUsageDiscountAdjustment planPhaseUsageDiscountAdjustment ) : base(planPhaseUsageDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public PlanPhaseUsageDiscountAdjustment(IReadOnlyDictionary rawData) @@ -316,10 +319,13 @@ public override void Validate() public PlanPhaseUsageDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanPhaseUsageDiscountAdjustmentFilter( PlanPhaseUsageDiscountAdjustmentFilter planPhaseUsageDiscountAdjustmentFilter ) : base(planPhaseUsageDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public PlanPhaseUsageDiscountAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs index 7b94ca3c8..2b829d4a6 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs @@ -67,8 +67,11 @@ public override void Validate() public MigrationCancelResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MigrationCancelResponse(MigrationCancelResponse migrationCancelResponse) : base(migrationCancelResponse) { } +#pragma warning restore CS8618 public MigrationCancelResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationListPageResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationListPageResponse.cs index 47f6ba52b..220bccdaa 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListPageResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListPageResponse.cs @@ -51,8 +51,11 @@ public override void Validate() public MigrationListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MigrationListPageResponse(MigrationListPageResponse migrationListPageResponse) : base(migrationListPageResponse) { } +#pragma warning restore CS8618 public MigrationListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs index 7188e8f9e..7899b8fa2 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs @@ -67,8 +67,11 @@ public override void Validate() public MigrationListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MigrationListResponse(MigrationListResponse migrationListResponse) : base(migrationListResponse) { } +#pragma warning restore CS8618 public MigrationListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs index 10e33b6ce..1e17e6b8f 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs @@ -65,8 +65,11 @@ public override void Validate() public MigrationRetrieveResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MigrationRetrieveResponse(MigrationRetrieveResponse migrationRetrieveResponse) : base(migrationRetrieveResponse) { } +#pragma warning restore CS8618 public MigrationRetrieveResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Plans/Plan.cs b/src/Orb/Models/Plans/Plan.cs index 7f23294a9..22fd4a2fb 100644 --- a/src/Orb/Models/Plans/Plan.cs +++ b/src/Orb/Models/Plans/Plan.cs @@ -379,11 +379,14 @@ public override void Validate() )] public Plan() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: base_plan, base_plan_id, currency, discount, maximum, maximum_amount, minimum, minimum_amount" )] public Plan(Plan plan) : base(plan) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: base_plan, base_plan_id, currency, discount, maximum, maximum_amount, minimum, minimum_amount" @@ -1030,8 +1033,11 @@ public override void Validate() public BasePlan() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BasePlan(BasePlan basePlan) : base(basePlan) { } +#pragma warning restore CS8618 public BasePlan(IReadOnlyDictionary rawData) { @@ -1200,8 +1206,11 @@ public override void Validate() public PlanPlanPhase() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanPlanPhase(PlanPlanPhase planPlanPhase) : base(planPlanPhase) { } +#pragma warning restore CS8618 public PlanPlanPhase(IReadOnlyDictionary rawData) { @@ -1326,8 +1335,11 @@ public override void Validate() public Product() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Product(Product product) : base(product) { } +#pragma warning restore CS8618 public Product(IReadOnlyDictionary rawData) { @@ -1437,8 +1449,11 @@ public override void Validate() public TrialConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TrialConfig(TrialConfig trialConfig) : base(trialConfig) { } +#pragma warning restore CS8618 public TrialConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Plans/PlanCreateParams.cs b/src/Orb/Models/Plans/PlanCreateParams.cs index 1f6b3e725..74addba60 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -349,8 +349,11 @@ public override void Validate() public Price() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Price(Price price) : base(price) { } +#pragma warning restore CS8618 public Price(IReadOnlyDictionary rawData) { @@ -3280,8 +3283,11 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } +#pragma warning restore CS8618 public BulkWithFilters(IReadOnlyDictionary rawData) { @@ -3371,8 +3377,11 @@ public override void Validate() public BulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { @@ -3445,8 +3454,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -3516,8 +3528,11 @@ public override void Validate() public Tier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Tier(Tier tier) : base(tier) { } +#pragma warning restore CS8618 public Tier(IReadOnlyDictionary rawData) { @@ -4182,8 +4197,11 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } +#pragma warning restore CS8618 public TieredWithProration(IReadOnlyDictionary rawData) { @@ -4316,8 +4334,11 @@ public override void Validate() public TieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationConfig(IReadOnlyDictionary rawData) { @@ -4399,10 +4420,13 @@ public override void Validate() public TieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfigTier( TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { @@ -5019,8 +5043,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -5188,10 +5215,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -5808,8 +5838,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -5977,10 +6010,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -6586,8 +6622,11 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percent(Percent percent) : base(percent) { } +#pragma warning restore CS8618 public Percent(IReadOnlyDictionary rawData) { @@ -6704,8 +6743,11 @@ public override void Validate() public PercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } +#pragma warning restore CS8618 public PercentConfig(IReadOnlyDictionary rawData) { @@ -7319,8 +7361,11 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutput(EventOutput eventOutput) : base(eventOutput) { } +#pragma warning restore CS8618 public EventOutput(IReadOnlyDictionary rawData) { @@ -7468,8 +7513,11 @@ public override void Validate() public EventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } +#pragma warning restore CS8618 public EventOutputConfig(IReadOnlyDictionary rawData) { @@ -7830,8 +7878,11 @@ public override void Validate() public Adjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Adjustment(Adjustment adjustment) : base(adjustment) { } +#pragma warning restore CS8618 public Adjustment(IReadOnlyDictionary rawData) { @@ -8413,8 +8464,11 @@ public override void Validate() public PlanPhase() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanPhase(PlanPhase planPhase) : base(planPhase) { } +#pragma warning restore CS8618 public PlanPhase(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Plans/PlanListPageResponse.cs b/src/Orb/Models/Plans/PlanListPageResponse.cs index e661892b9..a325128a7 100644 --- a/src/Orb/Models/Plans/PlanListPageResponse.cs +++ b/src/Orb/Models/Plans/PlanListPageResponse.cs @@ -46,8 +46,11 @@ public override void Validate() public PlanListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanListPageResponse(PlanListPageResponse planListPageResponse) : base(planListPageResponse) { } +#pragma warning restore CS8618 public PlanListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index f71357d6a..0d3290a21 100644 --- a/src/Orb/Models/Price.cs +++ b/src/Orb/Models/Price.cs @@ -3231,11 +3231,14 @@ public Unit() this.ModelType = JsonSerializer.SerializeToElement("unit"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public Unit(Unit unit) : base(unit) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -3434,8 +3437,11 @@ public override void Validate() public CompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CompositePriceFilter(CompositePriceFilter compositePriceFilter) : base(compositePriceFilter) { } +#pragma warning restore CS8618 public CompositePriceFilter(IReadOnlyDictionary rawData) { @@ -4279,11 +4285,14 @@ public Tiered() this.ModelType = JsonSerializer.SerializeToElement("tiered"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public Tiered(Tiered tiered) : base(tiered) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -4484,8 +4493,11 @@ public override void Validate() public TieredCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredCompositePriceFilter(TieredCompositePriceFilter tieredCompositePriceFilter) : base(tieredCompositePriceFilter) { } +#pragma warning restore CS8618 public TieredCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -5329,11 +5341,14 @@ public Bulk() this.ModelType = JsonSerializer.SerializeToElement("bulk"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public Bulk(Bulk bulk) : base(bulk) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -5534,8 +5549,11 @@ public override void Validate() public BulkCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkCompositePriceFilter(BulkCompositePriceFilter bulkCompositePriceFilter) : base(bulkCompositePriceFilter) { } +#pragma warning restore CS8618 public BulkCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -6389,11 +6407,14 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -6537,8 +6558,11 @@ public override void Validate() public BulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { @@ -6613,8 +6637,11 @@ public override void Validate() public BulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersConfigFilter(BulkWithFiltersConfigFilter bulkWithFiltersConfigFilter) : base(bulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 public BulkWithFiltersConfigFilter(IReadOnlyDictionary rawData) { @@ -6689,8 +6716,11 @@ public override void Validate() public BulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersConfigTier(BulkWithFiltersConfigTier bulkWithFiltersConfigTier) : base(bulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 public BulkWithFiltersConfigTier(IReadOnlyDictionary rawData) { @@ -6852,10 +6882,13 @@ public override void Validate() public BulkWithFiltersCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersCompositePriceFilter( BulkWithFiltersCompositePriceFilter bulkWithFiltersCompositePriceFilter ) : base(bulkWithFiltersCompositePriceFilter) { } +#pragma warning restore CS8618 public BulkWithFiltersCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -7702,11 +7735,14 @@ public Package() this.ModelType = JsonSerializer.SerializeToElement("package"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public Package(Package package) : base(package) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -7907,8 +7943,11 @@ public override void Validate() public PackageCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PackageCompositePriceFilter(PackageCompositePriceFilter packageCompositePriceFilter) : base(packageCompositePriceFilter) { } +#pragma warning restore CS8618 public PackageCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -8754,11 +8793,14 @@ public Matrix() this.ModelType = JsonSerializer.SerializeToElement("matrix"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public Matrix(Matrix matrix) : base(matrix) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -8959,8 +9001,11 @@ public override void Validate() public MatrixCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixCompositePriceFilter(MatrixCompositePriceFilter matrixCompositePriceFilter) : base(matrixCompositePriceFilter) { } +#pragma warning restore CS8618 public MatrixCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -9817,11 +9862,14 @@ public ThresholdTotalAmount() this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public ThresholdTotalAmount(ThresholdTotalAmount thresholdTotalAmount) : base(thresholdTotalAmount) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -10029,10 +10077,13 @@ public override void Validate() public ThresholdTotalAmountCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ThresholdTotalAmountCompositePriceFilter( ThresholdTotalAmountCompositePriceFilter thresholdTotalAmountCompositePriceFilter ) : base(thresholdTotalAmountCompositePriceFilter) { } +#pragma warning restore CS8618 public ThresholdTotalAmountCompositePriceFilter( IReadOnlyDictionary rawData @@ -10561,10 +10612,13 @@ public override void Validate() public ThresholdTotalAmountThresholdTotalAmountConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ThresholdTotalAmountThresholdTotalAmountConfig( ThresholdTotalAmountThresholdTotalAmountConfig thresholdTotalAmountThresholdTotalAmountConfig ) : base(thresholdTotalAmountThresholdTotalAmountConfig) { } +#pragma warning restore CS8618 public ThresholdTotalAmountThresholdTotalAmountConfig( IReadOnlyDictionary rawData @@ -10652,10 +10706,13 @@ public override void Validate() public ThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable( ThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable thresholdTotalAmountThresholdTotalAmountConfigConsumptionTable ) : base(thresholdTotalAmountThresholdTotalAmountConfigConsumptionTable) { } +#pragma warning restore CS8618 public ThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable( IReadOnlyDictionary rawData @@ -11079,11 +11136,14 @@ public TieredPackage() this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public TieredPackage(TieredPackage tieredPackage) : base(tieredPackage) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -11287,10 +11347,13 @@ public override void Validate() public TieredPackageCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageCompositePriceFilter( TieredPackageCompositePriceFilter tieredPackageCompositePriceFilter ) : base(tieredPackageCompositePriceFilter) { } +#pragma warning restore CS8618 public TieredPackageCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -11816,10 +11879,13 @@ public override void Validate() public TieredPackageTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageTieredPackageConfig( TieredPackageTieredPackageConfig tieredPackageTieredPackageConfig ) : base(tieredPackageTieredPackageConfig) { } +#pragma warning restore CS8618 public TieredPackageTieredPackageConfig(IReadOnlyDictionary rawData) { @@ -11894,10 +11960,13 @@ public override void Validate() public TieredPackageTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageTieredPackageConfigTier( TieredPackageTieredPackageConfigTier tieredPackageTieredPackageConfigTier ) : base(tieredPackageTieredPackageConfigTier) { } +#pragma warning restore CS8618 public TieredPackageTieredPackageConfigTier(IReadOnlyDictionary rawData) { @@ -12319,11 +12388,14 @@ public TieredWithMinimum() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public TieredWithMinimum(TieredWithMinimum tieredWithMinimum) : base(tieredWithMinimum) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -12529,10 +12601,13 @@ public override void Validate() public TieredWithMinimumCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithMinimumCompositePriceFilter( TieredWithMinimumCompositePriceFilter tieredWithMinimumCompositePriceFilter ) : base(tieredWithMinimumCompositePriceFilter) { } +#pragma warning restore CS8618 public TieredWithMinimumCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -13090,10 +13165,13 @@ public override void Validate() public TieredWithMinimumTieredWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithMinimumTieredWithMinimumConfig( TieredWithMinimumTieredWithMinimumConfig tieredWithMinimumTieredWithMinimumConfig ) : base(tieredWithMinimumTieredWithMinimumConfig) { } +#pragma warning restore CS8618 public TieredWithMinimumTieredWithMinimumConfig( IReadOnlyDictionary rawData @@ -13191,10 +13269,13 @@ public override void Validate() public TieredWithMinimumTieredWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithMinimumTieredWithMinimumConfigTier( TieredWithMinimumTieredWithMinimumConfigTier tieredWithMinimumTieredWithMinimumConfigTier ) : base(tieredWithMinimumTieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 public TieredWithMinimumTieredWithMinimumConfigTier( IReadOnlyDictionary rawData @@ -13616,11 +13697,14 @@ public GroupedTiered() this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedTiered(GroupedTiered groupedTiered) : base(groupedTiered) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -13824,10 +13908,13 @@ public override void Validate() public GroupedTieredCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredCompositePriceFilter( GroupedTieredCompositePriceFilter groupedTieredCompositePriceFilter ) : base(groupedTieredCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedTieredCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -14306,10 +14393,13 @@ public override void Validate() public GroupedTieredGroupedTieredConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredGroupedTieredConfig( GroupedTieredGroupedTieredConfig groupedTieredGroupedTieredConfig ) : base(groupedTieredGroupedTieredConfig) { } +#pragma warning restore CS8618 public GroupedTieredGroupedTieredConfig(IReadOnlyDictionary rawData) { @@ -14384,10 +14474,13 @@ public override void Validate() public GroupedTieredGroupedTieredConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredGroupedTieredConfigTier( GroupedTieredGroupedTieredConfigTier groupedTieredGroupedTieredConfigTier ) : base(groupedTieredGroupedTieredConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredGroupedTieredConfigTier(IReadOnlyDictionary rawData) { @@ -14858,11 +14951,14 @@ public TieredPackageWithMinimum() this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public TieredPackageWithMinimum(TieredPackageWithMinimum tieredPackageWithMinimum) : base(tieredPackageWithMinimum) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -15071,10 +15167,13 @@ public override void Validate() public TieredPackageWithMinimumCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumCompositePriceFilter( TieredPackageWithMinimumCompositePriceFilter tieredPackageWithMinimumCompositePriceFilter ) : base(tieredPackageWithMinimumCompositePriceFilter) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumCompositePriceFilter( IReadOnlyDictionary rawData @@ -15602,10 +15701,13 @@ public override void Validate() public TieredPackageWithMinimumTieredPackageWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumTieredPackageWithMinimumConfig( TieredPackageWithMinimumTieredPackageWithMinimumConfig tieredPackageWithMinimumTieredPackageWithMinimumConfig ) : base(tieredPackageWithMinimumTieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumTieredPackageWithMinimumConfig( IReadOnlyDictionary rawData @@ -15693,10 +15795,13 @@ public override void Validate() public TieredPackageWithMinimumTieredPackageWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumTieredPackageWithMinimumConfigTier( TieredPackageWithMinimumTieredPackageWithMinimumConfigTier tieredPackageWithMinimumTieredPackageWithMinimumConfigTier ) : base(tieredPackageWithMinimumTieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumTieredPackageWithMinimumConfigTier( IReadOnlyDictionary rawData @@ -16122,11 +16227,14 @@ public PackageWithAllocation() this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public PackageWithAllocation(PackageWithAllocation packageWithAllocation) : base(packageWithAllocation) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -16334,10 +16442,13 @@ public override void Validate() public PackageWithAllocationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PackageWithAllocationCompositePriceFilter( PackageWithAllocationCompositePriceFilter packageWithAllocationCompositePriceFilter ) : base(packageWithAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 public PackageWithAllocationCompositePriceFilter( IReadOnlyDictionary rawData @@ -16813,10 +16924,13 @@ public override void Validate() public PackageWithAllocationPackageWithAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PackageWithAllocationPackageWithAllocationConfig( PackageWithAllocationPackageWithAllocationConfig packageWithAllocationPackageWithAllocationConfig ) : base(packageWithAllocationPackageWithAllocationConfig) { } +#pragma warning restore CS8618 public PackageWithAllocationPackageWithAllocationConfig( IReadOnlyDictionary rawData @@ -17287,11 +17401,14 @@ public UnitWithPercent() this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public UnitWithPercent(UnitWithPercent unitWithPercent) : base(unitWithPercent) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -17495,10 +17612,13 @@ public override void Validate() public UnitWithPercentCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithPercentCompositePriceFilter( UnitWithPercentCompositePriceFilter unitWithPercentCompositePriceFilter ) : base(unitWithPercentCompositePriceFilter) { } +#pragma warning restore CS8618 public UnitWithPercentCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -18013,10 +18133,13 @@ public override void Validate() public UnitWithPercentUnitWithPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithPercentUnitWithPercentConfig( UnitWithPercentUnitWithPercentConfig unitWithPercentUnitWithPercentConfig ) : base(unitWithPercentUnitWithPercentConfig) { } +#pragma warning restore CS8618 public UnitWithPercentUnitWithPercentConfig(IReadOnlyDictionary rawData) { @@ -18438,11 +18561,14 @@ public MatrixWithAllocation() this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public MatrixWithAllocation(MatrixWithAllocation matrixWithAllocation) : base(matrixWithAllocation) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -18650,10 +18776,13 @@ public override void Validate() public MatrixWithAllocationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithAllocationCompositePriceFilter( MatrixWithAllocationCompositePriceFilter matrixWithAllocationCompositePriceFilter ) : base(matrixWithAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 public MatrixWithAllocationCompositePriceFilter( IReadOnlyDictionary rawData @@ -19514,11 +19643,14 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -19724,10 +19856,13 @@ public override void Validate() public TieredWithProrationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationCompositePriceFilter( TieredWithProrationCompositePriceFilter tieredWithProrationCompositePriceFilter ) : base(tieredWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 public TieredWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -20241,10 +20376,13 @@ public override void Validate() public TieredWithProrationTieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationTieredWithProrationConfig( TieredWithProrationTieredWithProrationConfig tieredWithProrationTieredWithProrationConfig ) : base(tieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData @@ -20334,10 +20472,13 @@ public override void Validate() public TieredWithProrationTieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationTieredWithProrationConfigTier( TieredWithProrationTieredWithProrationConfigTier tieredWithProrationTieredWithProrationConfigTier ) : base(tieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData @@ -20761,11 +20902,14 @@ public UnitWithProration() this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public UnitWithProration(UnitWithProration unitWithProration) : base(unitWithProration) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -20971,10 +21115,13 @@ public override void Validate() public UnitWithProrationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithProrationCompositePriceFilter( UnitWithProrationCompositePriceFilter unitWithProrationCompositePriceFilter ) : base(unitWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 public UnitWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -21476,10 +21623,13 @@ public override void Validate() public UnitWithProrationUnitWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithProrationUnitWithProrationConfig( UnitWithProrationUnitWithProrationConfig unitWithProrationUnitWithProrationConfig ) : base(unitWithProrationUnitWithProrationConfig) { } +#pragma warning restore CS8618 public UnitWithProrationUnitWithProrationConfig( IReadOnlyDictionary rawData @@ -21910,11 +22060,14 @@ public GroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedAllocation(GroupedAllocation groupedAllocation) : base(groupedAllocation) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -22120,10 +22273,13 @@ public override void Validate() public GroupedAllocationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedAllocationCompositePriceFilter( GroupedAllocationCompositePriceFilter groupedAllocationCompositePriceFilter ) : base(groupedAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedAllocationCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -22606,10 +22762,13 @@ public override void Validate() public GroupedAllocationGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedAllocationGroupedAllocationConfig( GroupedAllocationGroupedAllocationConfig groupedAllocationGroupedAllocationConfig ) : base(groupedAllocationGroupedAllocationConfig) { } +#pragma warning restore CS8618 public GroupedAllocationGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -23080,11 +23239,14 @@ public BulkWithProration() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public BulkWithProration(BulkWithProration bulkWithProration) : base(bulkWithProration) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -23210,10 +23372,13 @@ public override void Validate() public BulkWithProrationBulkWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationBulkWithProrationConfig( BulkWithProrationBulkWithProrationConfig bulkWithProrationBulkWithProrationConfig ) : base(bulkWithProrationBulkWithProrationConfig) { } +#pragma warning restore CS8618 public BulkWithProrationBulkWithProrationConfig( IReadOnlyDictionary rawData @@ -23303,10 +23468,13 @@ public override void Validate() public BulkWithProrationBulkWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationBulkWithProrationConfigTier( BulkWithProrationBulkWithProrationConfigTier bulkWithProrationBulkWithProrationConfigTier ) : base(bulkWithProrationBulkWithProrationConfigTier) { } +#pragma warning restore CS8618 public BulkWithProrationBulkWithProrationConfigTier( IReadOnlyDictionary rawData @@ -23471,10 +23639,13 @@ public override void Validate() public BulkWithProrationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationCompositePriceFilter( BulkWithProrationCompositePriceFilter bulkWithProrationCompositePriceFilter ) : base(bulkWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 public BulkWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -24335,11 +24506,14 @@ public GroupedWithProratedMinimum() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedWithProratedMinimum(GroupedWithProratedMinimum groupedWithProratedMinimum) : base(groupedWithProratedMinimum) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -24548,10 +24722,13 @@ public override void Validate() public GroupedWithProratedMinimumCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithProratedMinimumCompositePriceFilter( GroupedWithProratedMinimumCompositePriceFilter groupedWithProratedMinimumCompositePriceFilter ) : base(groupedWithProratedMinimumCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedWithProratedMinimumCompositePriceFilter( IReadOnlyDictionary rawData @@ -25037,10 +25214,13 @@ public override void Validate() public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( GroupedWithProratedMinimumGroupedWithProratedMinimumConfig groupedWithProratedMinimumGroupedWithProratedMinimumConfig ) : base(groupedWithProratedMinimumGroupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( IReadOnlyDictionary rawData @@ -25516,11 +25696,14 @@ public GroupedWithMeteredMinimum() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedWithMeteredMinimum(GroupedWithMeteredMinimum groupedWithMeteredMinimum) : base(groupedWithMeteredMinimum) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -25729,10 +25912,13 @@ public override void Validate() public GroupedWithMeteredMinimumCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumCompositePriceFilter( GroupedWithMeteredMinimumCompositePriceFilter groupedWithMeteredMinimumCompositePriceFilter ) : base(groupedWithMeteredMinimumCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumCompositePriceFilter( IReadOnlyDictionary rawData @@ -26282,10 +26468,13 @@ public override void Validate() public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig groupedWithMeteredMinimumGroupedWithMeteredMinimumConfig ) : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( IReadOnlyDictionary rawData @@ -26363,10 +26552,13 @@ public override void Validate() public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor ) : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( IReadOnlyDictionary rawData @@ -26450,10 +26642,13 @@ public override void Validate() public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount ) : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( IReadOnlyDictionary rawData @@ -26932,11 +27127,14 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -27148,10 +27346,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsCompositePriceFilter( GroupedWithMinMaxThresholdsCompositePriceFilter groupedWithMinMaxThresholdsCompositePriceFilter ) : base(groupedWithMinMaxThresholdsCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsCompositePriceFilter( IReadOnlyDictionary rawData @@ -27651,10 +27852,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -28123,11 +28327,14 @@ public MatrixWithDisplayName() this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) : base(matrixWithDisplayName) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -28335,10 +28542,13 @@ public override void Validate() public MatrixWithDisplayNameCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameCompositePriceFilter( MatrixWithDisplayNameCompositePriceFilter matrixWithDisplayNameCompositePriceFilter ) : base(matrixWithDisplayNameCompositePriceFilter) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameCompositePriceFilter( IReadOnlyDictionary rawData @@ -28819,10 +29029,13 @@ public override void Validate() public MatrixWithDisplayNameMatrixWithDisplayNameConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameMatrixWithDisplayNameConfig( MatrixWithDisplayNameMatrixWithDisplayNameConfig matrixWithDisplayNameMatrixWithDisplayNameConfig ) : base(matrixWithDisplayNameMatrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameMatrixWithDisplayNameConfig( IReadOnlyDictionary rawData @@ -28917,10 +29130,13 @@ public override void Validate() public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount ) : base(matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( IReadOnlyDictionary rawData @@ -29393,11 +29609,14 @@ public GroupedTieredPackage() this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) : base(groupedTieredPackage) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -29605,10 +29824,13 @@ public override void Validate() public GroupedTieredPackageCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageCompositePriceFilter( GroupedTieredPackageCompositePriceFilter groupedTieredPackageCompositePriceFilter ) : base(groupedTieredPackageCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedTieredPackageCompositePriceFilter( IReadOnlyDictionary rawData @@ -30102,10 +30324,13 @@ public override void Validate() public GroupedTieredPackageGroupedTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageGroupedTieredPackageConfig( GroupedTieredPackageGroupedTieredPackageConfig groupedTieredPackageGroupedTieredPackageConfig ) : base(groupedTieredPackageGroupedTieredPackageConfig) { } +#pragma warning restore CS8618 public GroupedTieredPackageGroupedTieredPackageConfig( IReadOnlyDictionary rawData @@ -30183,10 +30408,13 @@ public override void Validate() public GroupedTieredPackageGroupedTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageGroupedTieredPackageConfigTier( GroupedTieredPackageGroupedTieredPackageConfigTier groupedTieredPackageGroupedTieredPackageConfigTier ) : base(groupedTieredPackageGroupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredPackageGroupedTieredPackageConfigTier( IReadOnlyDictionary rawData @@ -30659,11 +30887,14 @@ public MaxGroupTieredPackage() this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) : base(maxGroupTieredPackage) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -30871,10 +31102,13 @@ public override void Validate() public MaxGroupTieredPackageCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageCompositePriceFilter( MaxGroupTieredPackageCompositePriceFilter maxGroupTieredPackageCompositePriceFilter ) : base(maxGroupTieredPackageCompositePriceFilter) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageCompositePriceFilter( IReadOnlyDictionary rawData @@ -31367,10 +31601,13 @@ public override void Validate() public MaxGroupTieredPackageMaxGroupTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageMaxGroupTieredPackageConfig( MaxGroupTieredPackageMaxGroupTieredPackageConfig maxGroupTieredPackageMaxGroupTieredPackageConfig ) : base(maxGroupTieredPackageMaxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageMaxGroupTieredPackageConfig( IReadOnlyDictionary rawData @@ -31448,10 +31685,13 @@ public override void Validate() public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( MaxGroupTieredPackageMaxGroupTieredPackageConfigTier maxGroupTieredPackageMaxGroupTieredPackageConfigTier ) : base(maxGroupTieredPackageMaxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( IReadOnlyDictionary rawData @@ -31926,6 +32166,8 @@ public ScalableMatrixWithUnitPricing() this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] @@ -31933,6 +32175,7 @@ public ScalableMatrixWithUnitPricing( ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing ) : base(scalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -32144,10 +32387,13 @@ public override void Validate() public ScalableMatrixWithUnitPricingCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingCompositePriceFilter( ScalableMatrixWithUnitPricingCompositePriceFilter scalableMatrixWithUnitPricingCompositePriceFilter ) : base(scalableMatrixWithUnitPricingCompositePriceFilter) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingCompositePriceFilter( IReadOnlyDictionary rawData @@ -32721,10 +32967,13 @@ public override void Validate() public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ) : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( IReadOnlyDictionary rawData @@ -32813,11 +33062,14 @@ public override void Validate() public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor ) : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData @@ -33251,6 +33503,8 @@ public ScalableMatrixWithTieredPricing() this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] @@ -33258,6 +33512,7 @@ public ScalableMatrixWithTieredPricing( ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing ) : base(scalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -33469,10 +33724,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingCompositePriceFilter( ScalableMatrixWithTieredPricingCompositePriceFilter scalableMatrixWithTieredPricingCompositePriceFilter ) : base(scalableMatrixWithTieredPricingCompositePriceFilter) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingCompositePriceFilter( IReadOnlyDictionary rawData @@ -34041,10 +34299,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig ) : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( IReadOnlyDictionary rawData @@ -34137,12 +34398,15 @@ public override void Validate() public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor ) : base( scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor ) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData @@ -34223,10 +34487,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier ) : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( IReadOnlyDictionary rawData @@ -34655,11 +34922,14 @@ public CumulativeGroupedBulk() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) : base(cumulativeGroupedBulk) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -34867,10 +35137,13 @@ public override void Validate() public CumulativeGroupedBulkCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedBulkCompositePriceFilter( CumulativeGroupedBulkCompositePriceFilter cumulativeGroupedBulkCompositePriceFilter ) : base(cumulativeGroupedBulkCompositePriceFilter) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkCompositePriceFilter( IReadOnlyDictionary rawData @@ -35348,10 +35621,13 @@ public override void Validate() public CumulativeGroupedBulkCumulativeGroupedBulkConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedBulkCumulativeGroupedBulkConfig( CumulativeGroupedBulkCumulativeGroupedBulkConfig cumulativeGroupedBulkCumulativeGroupedBulkConfig ) : base(cumulativeGroupedBulkCumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkCumulativeGroupedBulkConfig( IReadOnlyDictionary rawData @@ -35447,10 +35723,13 @@ public override void Validate() public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue ) : base(cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( IReadOnlyDictionary rawData @@ -35925,11 +36204,14 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -36141,10 +36423,13 @@ public override void Validate() public CumulativeGroupedAllocationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationCompositePriceFilter( CumulativeGroupedAllocationCompositePriceFilter cumulativeGroupedAllocationCompositePriceFilter ) : base(cumulativeGroupedAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationCompositePriceFilter( IReadOnlyDictionary rawData @@ -36644,10 +36929,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -37116,11 +37404,14 @@ public MinimumComposite() this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public MinimumComposite(MinimumComposite minimumComposite) : base(minimumComposite) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -37326,10 +37617,13 @@ public override void Validate() public MinimumCompositeCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumCompositeCompositePriceFilter( MinimumCompositeCompositePriceFilter minimumCompositeCompositePriceFilter ) : base(minimumCompositeCompositePriceFilter) { } +#pragma warning restore CS8618 public MinimumCompositeCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -37806,10 +38100,13 @@ public override void Validate() public MinimumCompositeMinimumCompositeConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumCompositeMinimumCompositeConfig( MinimumCompositeMinimumCompositeConfig minimumCompositeMinimumCompositeConfig ) : base(minimumCompositeMinimumCompositeConfig) { } +#pragma warning restore CS8618 public MinimumCompositeMinimumCompositeConfig(IReadOnlyDictionary rawData) { @@ -38274,11 +38571,14 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public Percent(Percent percent) : base(percent) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -38479,8 +38779,11 @@ public override void Validate() public PercentCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentCompositePriceFilter(PercentCompositePriceFilter percentCompositePriceFilter) : base(percentCompositePriceFilter) { } +#pragma warning restore CS8618 public PercentCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -38928,8 +39231,11 @@ public override void Validate() public PercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } +#pragma warning restore CS8618 public PercentConfig(IReadOnlyDictionary rawData) { @@ -39397,11 +39703,14 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public EventOutput(EventOutput eventOutput) : base(eventOutput) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -39605,10 +39914,13 @@ public override void Validate() public EventOutputCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutputCompositePriceFilter( EventOutputCompositePriceFilter eventOutputCompositePriceFilter ) : base(eventOutputCompositePriceFilter) { } +#pragma warning restore CS8618 public EventOutputCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -40088,8 +40400,11 @@ public override void Validate() public EventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } +#pragma warning restore CS8618 public EventOutputConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/PriceInterval.cs b/src/Orb/Models/PriceInterval.cs index 88b9049dc..a741eabf8 100644 --- a/src/Orb/Models/PriceInterval.cs +++ b/src/Orb/Models/PriceInterval.cs @@ -213,8 +213,11 @@ public override void Validate() public PriceInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceInterval(PriceInterval priceInterval) : base(priceInterval) { } +#pragma warning restore CS8618 public PriceInterval(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Prices/EvaluatePriceGroup.cs b/src/Orb/Models/Prices/EvaluatePriceGroup.cs index e6112fca0..e94835177 100644 --- a/src/Orb/Models/Prices/EvaluatePriceGroup.cs +++ b/src/Orb/Models/Prices/EvaluatePriceGroup.cs @@ -71,8 +71,11 @@ public override void Validate() public EvaluatePriceGroup() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EvaluatePriceGroup(EvaluatePriceGroup evaluatePriceGroup) : base(evaluatePriceGroup) { } +#pragma warning restore CS8618 public EvaluatePriceGroup(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Prices/PriceCreateParams.cs b/src/Orb/Models/Prices/PriceCreateParams.cs index 5f126121b..669c82bb7 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -3044,8 +3044,11 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } +#pragma warning restore CS8618 public BulkWithFilters(IReadOnlyDictionary rawData) { @@ -3135,8 +3138,11 @@ public override void Validate() public BulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { @@ -3209,8 +3215,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -3280,8 +3289,11 @@ public override void Validate() public Tier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Tier(Tier tier) : base(tier) { } +#pragma warning restore CS8618 public Tier(IReadOnlyDictionary rawData) { @@ -3932,8 +3944,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -4101,10 +4116,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -4705,8 +4723,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -4874,10 +4895,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -5467,8 +5491,11 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percent(Percent percent) : base(percent) { } +#pragma warning restore CS8618 public Percent(IReadOnlyDictionary rawData) { @@ -5585,8 +5612,11 @@ public override void Validate() public PercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } +#pragma warning restore CS8618 public PercentConfig(IReadOnlyDictionary rawData) { @@ -6184,8 +6214,11 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutput(EventOutput eventOutput) : base(eventOutput) { } +#pragma warning restore CS8618 public EventOutput(IReadOnlyDictionary rawData) { @@ -6333,8 +6366,11 @@ public override void Validate() public EventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } +#pragma warning restore CS8618 public EventOutputConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs index ab6cca778..5fde15e97 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -327,8 +327,11 @@ public override void Validate() public PriceEvaluation() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluation(PriceEvaluation priceEvaluation) : base(priceEvaluation) { } +#pragma warning restore CS8618 public PriceEvaluation(IReadOnlyDictionary rawData) { @@ -3224,8 +3227,11 @@ public PriceBulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceBulkWithFilters(PriceBulkWithFilters priceBulkWithFilters) : base(priceBulkWithFilters) { } +#pragma warning restore CS8618 public PriceBulkWithFilters(IReadOnlyDictionary rawData) { @@ -3327,10 +3333,13 @@ public override void Validate() public PriceBulkWithFiltersBulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceBulkWithFiltersBulkWithFiltersConfig( PriceBulkWithFiltersBulkWithFiltersConfig priceBulkWithFiltersBulkWithFiltersConfig ) : base(priceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 public PriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData @@ -3411,10 +3420,13 @@ public override void Validate() public PriceBulkWithFiltersBulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceBulkWithFiltersBulkWithFiltersConfigFilter( PriceBulkWithFiltersBulkWithFiltersConfigFilter priceBulkWithFiltersBulkWithFiltersConfigFilter ) : base(priceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 public PriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData @@ -3495,10 +3507,13 @@ public override void Validate() public PriceBulkWithFiltersBulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceBulkWithFiltersBulkWithFiltersConfigTier( PriceBulkWithFiltersBulkWithFiltersConfigTier priceBulkWithFiltersBulkWithFiltersConfigTier ) : base(priceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 public PriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData @@ -4171,10 +4186,13 @@ public PriceGroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceGroupedWithMinMaxThresholds( PriceGroupedWithMinMaxThresholds priceGroupedWithMinMaxThresholds ) : base(priceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public PriceGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -4343,10 +4361,13 @@ public override void Validate() public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base(priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -4956,10 +4977,13 @@ public PriceCumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceCumulativeGroupedAllocation( PriceCumulativeGroupedAllocation priceCumulativeGroupedAllocation ) : base(priceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public PriceCumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -5128,10 +5152,13 @@ public override void Validate() public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base(priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -5727,8 +5754,11 @@ public PricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PricePercent(PricePercent pricePercent) : base(pricePercent) { } +#pragma warning restore CS8618 public PricePercent(IReadOnlyDictionary rawData) { @@ -5847,8 +5877,11 @@ public override void Validate() public PricePercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PricePercentPercentConfig(PricePercentPercentConfig pricePercentPercentConfig) : base(pricePercentPercentConfig) { } +#pragma warning restore CS8618 public PricePercentPercentConfig(IReadOnlyDictionary rawData) { @@ -6454,8 +6487,11 @@ public PriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEventOutput(PriceEventOutput priceEventOutput) : base(priceEventOutput) { } +#pragma warning restore CS8618 public PriceEventOutput(IReadOnlyDictionary rawData) { @@ -6610,10 +6646,13 @@ public override void Validate() public PriceEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEventOutputEventOutputConfig( PriceEventOutputEventOutputConfig priceEventOutputEventOutputConfig ) : base(priceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public PriceEventOutputEventOutputConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleResponse.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleResponse.cs index bfdd2fa29..ff8382c5a 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleResponse.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleResponse.cs @@ -37,10 +37,13 @@ public override void Validate() public PriceEvaluateMultipleResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluateMultipleResponse( PriceEvaluateMultipleResponse priceEvaluateMultipleResponse ) : base(priceEvaluateMultipleResponse) { } +#pragma warning restore CS8618 public PriceEvaluateMultipleResponse(IReadOnlyDictionary rawData) { @@ -170,8 +173,11 @@ public override void Validate() public Data() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Data(Data data) : base(data) { } +#pragma warning restore CS8618 public Data(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs index 4af110327..83626d51d 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs @@ -342,8 +342,11 @@ public override void Validate() public Event() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Event(Event event_) : base(event_) { } +#pragma warning restore CS8618 public Event(IReadOnlyDictionary rawData) { @@ -472,10 +475,13 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluation() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluation( PriceEvaluatePreviewEventsParamsPriceEvaluation priceEvaluatePreviewEventsParamsPriceEvaluation ) : base(priceEvaluatePreviewEventsParamsPriceEvaluation) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluation( IReadOnlyDictionary rawData @@ -3582,10 +3588,13 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters priceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters( IReadOnlyDictionary rawData @@ -3695,12 +3704,15 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig ) : base( priceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig ) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData @@ -3788,12 +3800,15 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilter( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilter priceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base( priceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilter ) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData @@ -3881,12 +3896,15 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier priceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier ) : base( priceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier ) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData @@ -4597,10 +4615,13 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThre this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData @@ -4795,12 +4816,15 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -5428,10 +5452,13 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllo this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData @@ -5626,12 +5653,15 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base( priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -6250,10 +6280,13 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent priceEvaluatePreviewEventsParamsPriceEvaluationPricePercent ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPricePercent) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( IReadOnlyDictionary rawData @@ -6394,10 +6427,13 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig( PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig priceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig( IReadOnlyDictionary rawData @@ -7032,10 +7068,13 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput priceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput( IReadOnlyDictionary rawData @@ -7212,10 +7251,13 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputEventOutputConfig( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputEventOutputConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputEventOutputConfig ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsResponse.cs b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsResponse.cs index f8fb83b7e..b5fd78cad 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsResponse.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsResponse.cs @@ -45,10 +45,13 @@ public override void Validate() public PriceEvaluatePreviewEventsResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsResponse( PriceEvaluatePreviewEventsResponse priceEvaluatePreviewEventsResponse ) : base(priceEvaluatePreviewEventsResponse) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsResponse(IReadOnlyDictionary rawData) { @@ -185,10 +188,13 @@ public override void Validate() public PriceEvaluatePreviewEventsResponseData() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsResponseData( PriceEvaluatePreviewEventsResponseData priceEvaluatePreviewEventsResponseData ) : base(priceEvaluatePreviewEventsResponseData) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsResponseData(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Prices/PriceEvaluateResponse.cs b/src/Orb/Models/Prices/PriceEvaluateResponse.cs index 09543bd54..5a4baeee2 100644 --- a/src/Orb/Models/Prices/PriceEvaluateResponse.cs +++ b/src/Orb/Models/Prices/PriceEvaluateResponse.cs @@ -38,8 +38,11 @@ public override void Validate() public PriceEvaluateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluateResponse(PriceEvaluateResponse priceEvaluateResponse) : base(priceEvaluateResponse) { } +#pragma warning restore CS8618 public PriceEvaluateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Prices/PriceListPageResponse.cs b/src/Orb/Models/Prices/PriceListPageResponse.cs index b59a196f5..3a3ed5b7b 100644 --- a/src/Orb/Models/Prices/PriceListPageResponse.cs +++ b/src/Orb/Models/Prices/PriceListPageResponse.cs @@ -50,8 +50,11 @@ public override void Validate() public PriceListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceListPageResponse(PriceListPageResponse priceListPageResponse) : base(priceListPageResponse) { } +#pragma warning restore CS8618 public PriceListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SharedCreditNote.cs b/src/Orb/Models/SharedCreditNote.cs index 6d6f6de18..e98b81a7a 100644 --- a/src/Orb/Models/SharedCreditNote.cs +++ b/src/Orb/Models/SharedCreditNote.cs @@ -268,8 +268,11 @@ public override void Validate() public SharedCreditNote() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SharedCreditNote(SharedCreditNote sharedCreditNote) : base(sharedCreditNote) { } +#pragma warning restore CS8618 public SharedCreditNote(IReadOnlyDictionary rawData) { @@ -475,8 +478,11 @@ public override void Validate() public SharedCreditNoteLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SharedCreditNoteLineItem(SharedCreditNoteLineItem sharedCreditNoteLineItem) : base(sharedCreditNoteLineItem) { } +#pragma warning restore CS8618 public SharedCreditNoteLineItem(IReadOnlyDictionary rawData) { @@ -603,8 +609,11 @@ public override void Validate() public Discount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Discount(Discount discount) : base(discount) { } +#pragma warning restore CS8618 public Discount(IReadOnlyDictionary rawData) { @@ -758,8 +767,11 @@ public override void Validate() public MaximumAmountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaximumAmountAdjustment(MaximumAmountAdjustment maximumAmountAdjustment) : base(maximumAmountAdjustment) { } +#pragma warning restore CS8618 public MaximumAmountAdjustment(IReadOnlyDictionary rawData) { @@ -865,8 +877,11 @@ public override void Validate() public AppliesToPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AppliesToPrice(AppliesToPrice appliesToPrice) : base(appliesToPrice) { } +#pragma warning restore CS8618 public AppliesToPrice(IReadOnlyDictionary rawData) { @@ -1065,8 +1080,11 @@ public override void Validate() public SharedCreditNoteDiscount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SharedCreditNoteDiscount(SharedCreditNoteDiscount sharedCreditNoteDiscount) : base(sharedCreditNoteDiscount) { } +#pragma warning restore CS8618 public SharedCreditNoteDiscount(IReadOnlyDictionary rawData) { @@ -1177,10 +1195,13 @@ public override void Validate() public SharedCreditNoteDiscountAppliesToPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SharedCreditNoteDiscountAppliesToPrice( SharedCreditNoteDiscountAppliesToPrice sharedCreditNoteDiscountAppliesToPrice ) : base(sharedCreditNoteDiscountAppliesToPrice) { } +#pragma warning restore CS8618 public SharedCreditNoteDiscountAppliesToPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SharedTier.cs b/src/Orb/Models/SharedTier.cs index ae4dd1b25..40fff3e36 100644 --- a/src/Orb/Models/SharedTier.cs +++ b/src/Orb/Models/SharedTier.cs @@ -63,8 +63,11 @@ public override void Validate() public SharedTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SharedTier(SharedTier sharedTier) : base(sharedTier) { } +#pragma warning restore CS8618 public SharedTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SharedTieredConversionRateConfig.cs b/src/Orb/Models/SharedTieredConversionRateConfig.cs index e7a09af91..7144773b5 100644 --- a/src/Orb/Models/SharedTieredConversionRateConfig.cs +++ b/src/Orb/Models/SharedTieredConversionRateConfig.cs @@ -48,10 +48,13 @@ public override void Validate() public SharedTieredConversionRateConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SharedTieredConversionRateConfig( SharedTieredConversionRateConfig sharedTieredConversionRateConfig ) : base(sharedTieredConversionRateConfig) { } +#pragma warning restore CS8618 public SharedTieredConversionRateConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SharedUnitConversionRateConfig.cs b/src/Orb/Models/SharedUnitConversionRateConfig.cs index 5bd775460..be604b10b 100644 --- a/src/Orb/Models/SharedUnitConversionRateConfig.cs +++ b/src/Orb/Models/SharedUnitConversionRateConfig.cs @@ -51,10 +51,13 @@ public override void Validate() public SharedUnitConversionRateConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SharedUnitConversionRateConfig( SharedUnitConversionRateConfig sharedUnitConversionRateConfig ) : base(sharedUnitConversionRateConfig) { } +#pragma warning restore CS8618 public SharedUnitConversionRateConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubLineItemGrouping.cs b/src/Orb/Models/SubLineItemGrouping.cs index 1adf3f542..5cbef8604 100644 --- a/src/Orb/Models/SubLineItemGrouping.cs +++ b/src/Orb/Models/SubLineItemGrouping.cs @@ -42,8 +42,11 @@ public override void Validate() public SubLineItemGrouping() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubLineItemGrouping(SubLineItemGrouping subLineItemGrouping) : base(subLineItemGrouping) { } +#pragma warning restore CS8618 public SubLineItemGrouping(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubLineItemMatrixConfig.cs b/src/Orb/Models/SubLineItemMatrixConfig.cs index 5c65ed785..4cd9836cc 100644 --- a/src/Orb/Models/SubLineItemMatrixConfig.cs +++ b/src/Orb/Models/SubLineItemMatrixConfig.cs @@ -38,8 +38,11 @@ public override void Validate() public SubLineItemMatrixConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubLineItemMatrixConfig(SubLineItemMatrixConfig subLineItemMatrixConfig) : base(subLineItemMatrixConfig) { } +#pragma warning restore CS8618 public SubLineItemMatrixConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubscriptionChangeMinified.cs b/src/Orb/Models/SubscriptionChangeMinified.cs index 57fbe9d41..f0c8ddf21 100644 --- a/src/Orb/Models/SubscriptionChangeMinified.cs +++ b/src/Orb/Models/SubscriptionChangeMinified.cs @@ -30,8 +30,11 @@ public override void Validate() public SubscriptionChangeMinified() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeMinified(SubscriptionChangeMinified subscriptionChangeMinified) : base(subscriptionChangeMinified) { } +#pragma warning restore CS8618 public SubscriptionChangeMinified(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs b/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs index 29da66b4c..f422b5d00 100644 --- a/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs +++ b/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs @@ -516,11 +516,14 @@ public override void Validate() )] public MutatedSubscription() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount_intervals, maximum_intervals, minimum_intervals" )] public MutatedSubscription(MutatedSubscription mutatedSubscription) : base(mutatedSubscription) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount_intervals, maximum_intervals, minimum_intervals" diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyResponse.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyResponse.cs index 1e408ef14..49b004fe2 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyResponse.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyResponse.cs @@ -176,10 +176,13 @@ public override void Validate() public SubscriptionChangeApplyResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeApplyResponse( SubscriptionChangeApplyResponse subscriptionChangeApplyResponse ) : base(subscriptionChangeApplyResponse) { } +#pragma warning restore CS8618 public SubscriptionChangeApplyResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelResponse.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelResponse.cs index 14aee65eb..1972267a7 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelResponse.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelResponse.cs @@ -176,10 +176,13 @@ public override void Validate() public SubscriptionChangeCancelResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeCancelResponse( SubscriptionChangeCancelResponse subscriptionChangeCancelResponse ) : base(subscriptionChangeCancelResponse) { } +#pragma warning restore CS8618 public SubscriptionChangeCancelResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPageResponse.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPageResponse.cs index 1054ddd6b..8fb8533ce 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPageResponse.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public SubscriptionChangeListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeListPageResponse( SubscriptionChangeListPageResponse subscriptionChangeListPageResponse ) : base(subscriptionChangeListPageResponse) { } +#pragma warning restore CS8618 public SubscriptionChangeListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListResponse.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListResponse.cs index 4c9359567..7b4b20b81 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListResponse.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListResponse.cs @@ -101,10 +101,13 @@ public override void Validate() public SubscriptionChangeListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeListResponse( SubscriptionChangeListResponse subscriptionChangeListResponse ) : base(subscriptionChangeListResponse) { } +#pragma warning restore CS8618 public SubscriptionChangeListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponse.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponse.cs index 613a9141e..f981fdc24 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponse.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponse.cs @@ -176,10 +176,13 @@ public override void Validate() public SubscriptionChangeRetrieveResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeRetrieveResponse( SubscriptionChangeRetrieveResponse subscriptionChangeRetrieveResponse ) : base(subscriptionChangeRetrieveResponse) { } +#pragma warning restore CS8618 public SubscriptionChangeRetrieveResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubscriptionMinified.cs b/src/Orb/Models/SubscriptionMinified.cs index ce72e02eb..72d0d51b4 100644 --- a/src/Orb/Models/SubscriptionMinified.cs +++ b/src/Orb/Models/SubscriptionMinified.cs @@ -28,8 +28,11 @@ public override void Validate() public SubscriptionMinified() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionMinified(SubscriptionMinified subscriptionMinified) : base(subscriptionMinified) { } +#pragma warning restore CS8618 public SubscriptionMinified(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/SubscriptionTrialInfo.cs b/src/Orb/Models/SubscriptionTrialInfo.cs index 1d3af11ae..ef9ead459 100644 --- a/src/Orb/Models/SubscriptionTrialInfo.cs +++ b/src/Orb/Models/SubscriptionTrialInfo.cs @@ -29,8 +29,11 @@ public override void Validate() public SubscriptionTrialInfo() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionTrialInfo(SubscriptionTrialInfo subscriptionTrialInfo) : base(subscriptionTrialInfo) { } +#pragma warning restore CS8618 public SubscriptionTrialInfo(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/DiscountOverride.cs b/src/Orb/Models/Subscriptions/DiscountOverride.cs index a160cbe7b..bfd824a85 100644 --- a/src/Orb/Models/Subscriptions/DiscountOverride.cs +++ b/src/Orb/Models/Subscriptions/DiscountOverride.cs @@ -74,8 +74,11 @@ public override void Validate() public DiscountOverride() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DiscountOverride(DiscountOverride discountOverride) : base(discountOverride) { } +#pragma warning restore CS8618 public DiscountOverride(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs index 74a121d1f..c3738bafd 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs @@ -296,8 +296,11 @@ public override void Validate() public NewSubscriptionBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionBulkPrice(NewSubscriptionBulkPrice newSubscriptionBulkPrice) : base(newSubscriptionBulkPrice) { } +#pragma warning restore CS8618 public NewSubscriptionBulkPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs index 2661dfa47..cbdc0dedb 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewSubscriptionBulkWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionBulkWithProrationPrice( NewSubscriptionBulkWithProrationPrice newSubscriptionBulkWithProrationPrice ) : base(newSubscriptionBulkWithProrationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionBulkWithProrationPrice(IReadOnlyDictionary rawData) { @@ -378,8 +381,11 @@ public override void Validate() public BulkWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationConfig(BulkWithProrationConfig bulkWithProrationConfig) : base(bulkWithProrationConfig) { } +#pragma warning restore CS8618 public BulkWithProrationConfig(IReadOnlyDictionary rawData) { @@ -461,8 +467,11 @@ public override void Validate() public BulkWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationConfigTier(BulkWithProrationConfigTier bulkWithProrationConfigTier) : base(bulkWithProrationConfigTier) { } +#pragma warning restore CS8618 public BulkWithProrationConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs index f3c60a36e..56727589b 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewSubscriptionCumulativeGroupedBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionCumulativeGroupedBulkPrice( NewSubscriptionCumulativeGroupedBulkPrice newSubscriptionCumulativeGroupedBulkPrice ) : base(newSubscriptionCumulativeGroupedBulkPrice) { } +#pragma warning restore CS8618 public NewSubscriptionCumulativeGroupedBulkPrice( IReadOnlyDictionary rawData @@ -453,8 +456,11 @@ public override void Validate() public CumulativeGroupedBulkConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedBulkConfig(CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig) : base(cumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkConfig(IReadOnlyDictionary rawData) { @@ -541,8 +547,11 @@ public override void Validate() public DimensionValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionValue(DimensionValue dimensionValue) : base(dimensionValue) { } +#pragma warning restore CS8618 public DimensionValue(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs index cb71dda29..49b7a74e5 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs @@ -303,10 +303,13 @@ public override void Validate() public NewSubscriptionGroupedAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedAllocationPrice( NewSubscriptionGroupedAllocationPrice newSubscriptionGroupedAllocationPrice ) : base(newSubscriptionGroupedAllocationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedAllocationPrice(IReadOnlyDictionary rawData) { @@ -454,8 +457,11 @@ public override void Validate() public GroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedAllocationConfig(GroupedAllocationConfig groupedAllocationConfig) : base(groupedAllocationConfig) { } +#pragma warning restore CS8618 public GroupedAllocationConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs index b4d29c042..68c4f050a 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewSubscriptionGroupedTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedTieredPackagePrice( NewSubscriptionGroupedTieredPackagePrice newSubscriptionGroupedTieredPackagePrice ) : base(newSubscriptionGroupedTieredPackagePrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedTieredPackagePrice( IReadOnlyDictionary rawData @@ -468,8 +471,11 @@ public override void Validate() public GroupedTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageConfig(GroupedTieredPackageConfig groupedTieredPackageConfig) : base(groupedTieredPackageConfig) { } +#pragma warning restore CS8618 public GroupedTieredPackageConfig(IReadOnlyDictionary rawData) { @@ -544,10 +550,13 @@ public override void Validate() public GroupedTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageConfigTier( GroupedTieredPackageConfigTier groupedTieredPackageConfigTier ) : base(groupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredPackageConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs index 577d98a6f..41a964457 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs @@ -302,10 +302,13 @@ public override void Validate() public NewSubscriptionGroupedTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedTieredPrice( NewSubscriptionGroupedTieredPrice newSubscriptionGroupedTieredPrice ) : base(newSubscriptionGroupedTieredPrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedTieredPrice(IReadOnlyDictionary rawData) { @@ -447,8 +450,11 @@ public override void Validate() public GroupedTieredConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) : base(groupedTieredConfig) { } +#pragma warning restore CS8618 public GroupedTieredConfig(IReadOnlyDictionary rawData) { @@ -517,8 +523,11 @@ public override void Validate() public GroupedTieredConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) : base(groupedTieredConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs index dedb78918..c38a33811 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs @@ -307,10 +307,13 @@ public override void Validate() public NewSubscriptionGroupedWithMeteredMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedWithMeteredMinimumPrice( NewSubscriptionGroupedWithMeteredMinimumPrice newSubscriptionGroupedWithMeteredMinimumPrice ) : base(newSubscriptionGroupedWithMeteredMinimumPrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedWithMeteredMinimumPrice( IReadOnlyDictionary rawData @@ -527,10 +530,13 @@ public override void Validate() public GroupedWithMeteredMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumConfig( GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig ) : base(groupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumConfig(IReadOnlyDictionary rawData) { @@ -597,8 +603,11 @@ public override void Validate() public ScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalingFactor(ScalingFactor scalingFactor) : base(scalingFactor) { } +#pragma warning restore CS8618 public ScalingFactor(IReadOnlyDictionary rawData) { @@ -665,8 +674,11 @@ public override void Validate() public UnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitAmount(UnitAmount unitAmount) : base(unitAmount) { } +#pragma warning restore CS8618 public UnitAmount(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs index 7180a9f90..1b446af59 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs @@ -306,10 +306,13 @@ public override void Validate() public NewSubscriptionGroupedWithProratedMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedWithProratedMinimumPrice( NewSubscriptionGroupedWithProratedMinimumPrice newSubscriptionGroupedWithProratedMinimumPrice ) : base(newSubscriptionGroupedWithProratedMinimumPrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedWithProratedMinimumPrice( IReadOnlyDictionary rawData @@ -464,10 +467,13 @@ public override void Validate() public GroupedWithProratedMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithProratedMinimumConfig( GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig ) : base(groupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithProratedMinimumConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs index d505ad247..6f683c8b9 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs @@ -298,8 +298,11 @@ public override void Validate() public NewSubscriptionMatrixPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMatrixPrice(NewSubscriptionMatrixPrice newSubscriptionMatrixPrice) : base(newSubscriptionMatrixPrice) { } +#pragma warning restore CS8618 public NewSubscriptionMatrixPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs index a507d2ac1..46027842b 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs @@ -303,10 +303,13 @@ public override void Validate() public NewSubscriptionMatrixWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMatrixWithAllocationPrice( NewSubscriptionMatrixWithAllocationPrice newSubscriptionMatrixWithAllocationPrice ) : base(newSubscriptionMatrixWithAllocationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionMatrixWithAllocationPrice( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs index 5436dbabf..89eba9f1c 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewSubscriptionMatrixWithDisplayNamePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMatrixWithDisplayNamePrice( NewSubscriptionMatrixWithDisplayNamePrice newSubscriptionMatrixWithDisplayNamePrice ) : base(newSubscriptionMatrixWithDisplayNamePrice) { } +#pragma warning restore CS8618 public NewSubscriptionMatrixWithDisplayNamePrice( IReadOnlyDictionary rawData @@ -456,8 +459,11 @@ public override void Validate() public MatrixWithDisplayNameConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameConfig(MatrixWithDisplayNameConfig matrixWithDisplayNameConfig) : base(matrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameConfig(IReadOnlyDictionary rawData) { @@ -549,10 +555,13 @@ public override void Validate() public MatrixWithDisplayNameConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameConfigUnitAmount( MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount ) : base(matrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameConfigUnitAmount(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs index 5ddb44a80..1966893ed 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewSubscriptionMaxGroupTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMaxGroupTieredPackagePrice( NewSubscriptionMaxGroupTieredPackagePrice newSubscriptionMaxGroupTieredPackagePrice ) : base(newSubscriptionMaxGroupTieredPackagePrice) { } +#pragma warning restore CS8618 public NewSubscriptionMaxGroupTieredPackagePrice( IReadOnlyDictionary rawData @@ -467,8 +470,11 @@ public override void Validate() public MaxGroupTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageConfig(MaxGroupTieredPackageConfig maxGroupTieredPackageConfig) : base(maxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageConfig(IReadOnlyDictionary rawData) { @@ -543,10 +549,13 @@ public override void Validate() public MaxGroupTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageConfigTier( MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier ) : base(maxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs index 2fbc8b53f..706e9d283 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs @@ -303,10 +303,13 @@ public override void Validate() public NewSubscriptionMinimumCompositePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMinimumCompositePrice( NewSubscriptionMinimumCompositePrice newSubscriptionMinimumCompositePrice ) : base(newSubscriptionMinimumCompositePrice) { } +#pragma warning restore CS8618 public NewSubscriptionMinimumCompositePrice(IReadOnlyDictionary rawData) { @@ -448,8 +451,11 @@ public override void Validate() public MinimumCompositeConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumCompositeConfig(MinimumCompositeConfig minimumCompositeConfig) : base(minimumCompositeConfig) { } +#pragma warning restore CS8618 public MinimumCompositeConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs index 7d15cb98a..87c01662d 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs @@ -298,8 +298,11 @@ public override void Validate() public NewSubscriptionPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionPackagePrice(NewSubscriptionPackagePrice newSubscriptionPackagePrice) : base(newSubscriptionPackagePrice) { } +#pragma warning restore CS8618 public NewSubscriptionPackagePrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs index a241b6118..509f0d605 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs @@ -303,10 +303,13 @@ public override void Validate() public NewSubscriptionPackageWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionPackageWithAllocationPrice( NewSubscriptionPackageWithAllocationPrice newSubscriptionPackageWithAllocationPrice ) : base(newSubscriptionPackageWithAllocationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionPackageWithAllocationPrice( IReadOnlyDictionary rawData @@ -496,8 +499,11 @@ public override void Validate() public PackageWithAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PackageWithAllocationConfig(PackageWithAllocationConfig packageWithAllocationConfig) : base(packageWithAllocationConfig) { } +#pragma warning restore CS8618 public PackageWithAllocationConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs index 304d377ee..b520b6d52 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs @@ -310,10 +310,13 @@ public override void Validate() public NewSubscriptionScalableMatrixWithTieredPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionScalableMatrixWithTieredPricingPrice( NewSubscriptionScalableMatrixWithTieredPricingPrice newSubscriptionScalableMatrixWithTieredPricingPrice ) : base(newSubscriptionScalableMatrixWithTieredPricingPrice) { } +#pragma warning restore CS8618 public NewSubscriptionScalableMatrixWithTieredPricingPrice( IReadOnlyDictionary rawData @@ -551,10 +554,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingConfig( ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig ) : base(scalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingConfig(IReadOnlyDictionary rawData) { @@ -633,8 +639,11 @@ public override void Validate() public MatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixScalingFactor(MatrixScalingFactor matrixScalingFactor) : base(matrixScalingFactor) { } +#pragma warning restore CS8618 public MatrixScalingFactor(IReadOnlyDictionary rawData) { @@ -705,10 +714,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingConfigTier( ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier ) : base(scalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingConfigTier( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs index d93a3cf8d..dc0fcf029 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs @@ -310,10 +310,13 @@ public override void Validate() public NewSubscriptionScalableMatrixWithUnitPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionScalableMatrixWithUnitPricingPrice( NewSubscriptionScalableMatrixWithUnitPricingPrice newSubscriptionScalableMatrixWithUnitPricingPrice ) : base(newSubscriptionScalableMatrixWithUnitPricingPrice) { } +#pragma warning restore CS8618 public NewSubscriptionScalableMatrixWithUnitPricingPrice( IReadOnlyDictionary rawData @@ -554,10 +557,13 @@ public override void Validate() public ScalableMatrixWithUnitPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingConfig( ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig ) : base(scalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingConfig(IReadOnlyDictionary rawData) { @@ -640,10 +646,13 @@ public override void Validate() public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor( ScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingConfigMatrixScalingFactor ) : base(scalableMatrixWithUnitPricingConfigMatrixScalingFactor) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs index b20a1d51a..7733eb122 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewSubscriptionThresholdTotalAmountPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionThresholdTotalAmountPrice( NewSubscriptionThresholdTotalAmountPrice newSubscriptionThresholdTotalAmountPrice ) : base(newSubscriptionThresholdTotalAmountPrice) { } +#pragma warning restore CS8618 public NewSubscriptionThresholdTotalAmountPrice( IReadOnlyDictionary rawData @@ -504,8 +507,11 @@ public override void Validate() public ThresholdTotalAmountConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ThresholdTotalAmountConfig(ThresholdTotalAmountConfig thresholdTotalAmountConfig) : base(thresholdTotalAmountConfig) { } +#pragma warning restore CS8618 public ThresholdTotalAmountConfig(IReadOnlyDictionary rawData) { @@ -582,8 +588,11 @@ public override void Validate() public ConsumptionTable() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ConsumptionTable(ConsumptionTable consumptionTable) : base(consumptionTable) { } +#pragma warning restore CS8618 public ConsumptionTable(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs index 3e3342e21..7a481a530 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs @@ -302,10 +302,13 @@ public override void Validate() public NewSubscriptionTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionTieredPackagePrice( NewSubscriptionTieredPackagePrice newSubscriptionTieredPackagePrice ) : base(newSubscriptionTieredPackagePrice) { } +#pragma warning restore CS8618 public NewSubscriptionTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -492,8 +495,11 @@ public override void Validate() public TieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageConfig(TieredPackageConfig tieredPackageConfig) : base(tieredPackageConfig) { } +#pragma warning restore CS8618 public TieredPackageConfig(IReadOnlyDictionary rawData) { @@ -562,8 +568,11 @@ public override void Validate() public TieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageConfigTier(TieredPackageConfigTier tieredPackageConfigTier) : base(tieredPackageConfigTier) { } +#pragma warning restore CS8618 public TieredPackageConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs index 6d31b48f7..8d2b5353f 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewSubscriptionTieredPackageWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionTieredPackageWithMinimumPrice( NewSubscriptionTieredPackageWithMinimumPrice newSubscriptionTieredPackageWithMinimumPrice ) : base(newSubscriptionTieredPackageWithMinimumPrice) { } +#pragma warning restore CS8618 public NewSubscriptionTieredPackageWithMinimumPrice( IReadOnlyDictionary rawData @@ -504,10 +507,13 @@ public override void Validate() public TieredPackageWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumConfig( TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig ) : base(tieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumConfig(IReadOnlyDictionary rawData) { @@ -590,10 +596,13 @@ public override void Validate() public TieredPackageWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumConfigTier( TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier ) : base(tieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs index d3dbefc1d..7c8041198 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs @@ -298,8 +298,11 @@ public override void Validate() public NewSubscriptionTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionTieredPrice(NewSubscriptionTieredPrice newSubscriptionTieredPrice) : base(newSubscriptionTieredPrice) { } +#pragma warning restore CS8618 public NewSubscriptionTieredPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs index cef8a9616..a6ae2f2af 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs @@ -304,10 +304,13 @@ public override void Validate() public NewSubscriptionTieredWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionTieredWithMinimumPrice( NewSubscriptionTieredWithMinimumPrice newSubscriptionTieredWithMinimumPrice ) : base(newSubscriptionTieredWithMinimumPrice) { } +#pragma warning restore CS8618 public NewSubscriptionTieredWithMinimumPrice(IReadOnlyDictionary rawData) { @@ -530,8 +533,11 @@ public override void Validate() public TieredWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) : base(tieredWithMinimumConfig) { } +#pragma warning restore CS8618 public TieredWithMinimumConfig(IReadOnlyDictionary rawData) { @@ -621,8 +627,11 @@ public override void Validate() public TieredWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithMinimumConfigTier(TieredWithMinimumConfigTier tieredWithMinimumConfigTier) : base(tieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 public TieredWithMinimumConfigTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs index 5d518a9cb..fa959a1b1 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs @@ -298,8 +298,11 @@ public override void Validate() public NewSubscriptionUnitPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionUnitPrice(NewSubscriptionUnitPrice newSubscriptionUnitPrice) : base(newSubscriptionUnitPrice) { } +#pragma warning restore CS8618 public NewSubscriptionUnitPrice(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs index ba93e752f..fb61fa4e1 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs @@ -301,10 +301,13 @@ public override void Validate() public NewSubscriptionUnitWithPercentPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionUnitWithPercentPrice( NewSubscriptionUnitWithPercentPrice newSubscriptionUnitWithPercentPrice ) : base(newSubscriptionUnitWithPercentPrice) { } +#pragma warning restore CS8618 public NewSubscriptionUnitWithPercentPrice(IReadOnlyDictionary rawData) { @@ -482,8 +485,11 @@ public override void Validate() public UnitWithPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithPercentConfig(UnitWithPercentConfig unitWithPercentConfig) : base(unitWithPercentConfig) { } +#pragma warning restore CS8618 public UnitWithPercentConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs index 33d03f2e8..82a5b999c 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs @@ -303,10 +303,13 @@ public override void Validate() public NewSubscriptionUnitWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionUnitWithProrationPrice( NewSubscriptionUnitWithProrationPrice newSubscriptionUnitWithProrationPrice ) : base(newSubscriptionUnitWithProrationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionUnitWithProrationPrice(IReadOnlyDictionary rawData) { @@ -473,8 +476,11 @@ public override void Validate() public UnitWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithProrationConfig(UnitWithProrationConfig unitWithProrationConfig) : base(unitWithProrationConfig) { } +#pragma warning restore CS8618 public UnitWithProrationConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/Subscription.cs b/src/Orb/Models/Subscriptions/Subscription.cs index d98cab13e..e3ce0f664 100644 --- a/src/Orb/Models/Subscriptions/Subscription.cs +++ b/src/Orb/Models/Subscriptions/Subscription.cs @@ -517,11 +517,14 @@ public override void Validate() )] public Subscription() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount_intervals, maximum_intervals, minimum_intervals" )] public Subscription(Subscription subscription) : base(subscription) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount_intervals, maximum_intervals, minimum_intervals" diff --git a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs index 96de90d5f..bbd1cc96f 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -909,8 +909,11 @@ public override void Validate() public AddAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddAdjustment(AddAdjustment addAdjustment) : base(addAdjustment) { } +#pragma warning restore CS8618 public AddAdjustment(IReadOnlyDictionary rawData) { @@ -1590,8 +1593,11 @@ public override void Validate() public AddPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddPrice(AddPrice addPrice) : base(addPrice) { } +#pragma warning restore CS8618 public AddPrice(IReadOnlyDictionary rawData) { @@ -4597,8 +4603,11 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } +#pragma warning restore CS8618 public BulkWithFilters(IReadOnlyDictionary rawData) { @@ -4688,8 +4697,11 @@ public override void Validate() public BulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { @@ -4762,8 +4774,11 @@ public override void Validate() public Filter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -4833,8 +4848,11 @@ public override void Validate() public Tier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Tier(Tier tier) : base(tier) { } +#pragma warning restore CS8618 public Tier(IReadOnlyDictionary rawData) { @@ -5499,8 +5517,11 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } +#pragma warning restore CS8618 public TieredWithProration(IReadOnlyDictionary rawData) { @@ -5633,8 +5654,11 @@ public override void Validate() public TieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationConfig(IReadOnlyDictionary rawData) { @@ -5716,10 +5740,13 @@ public override void Validate() public TieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfigTier( TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { @@ -6336,8 +6363,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -6505,10 +6535,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -7125,8 +7158,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -7294,10 +7330,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -7903,8 +7942,11 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percent(Percent percent) : base(percent) { } +#pragma warning restore CS8618 public Percent(IReadOnlyDictionary rawData) { @@ -8021,8 +8063,11 @@ public override void Validate() public PercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } +#pragma warning restore CS8618 public PercentConfig(IReadOnlyDictionary rawData) { @@ -8636,8 +8681,11 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutput(EventOutput eventOutput) : base(eventOutput) { } +#pragma warning restore CS8618 public EventOutput(IReadOnlyDictionary rawData) { @@ -8785,8 +8833,11 @@ public override void Validate() public EventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } +#pragma warning restore CS8618 public EventOutputConfig(IReadOnlyDictionary rawData) { @@ -9181,8 +9232,11 @@ public override void Validate() public RemoveAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public RemoveAdjustment(RemoveAdjustment removeAdjustment) : base(removeAdjustment) { } +#pragma warning restore CS8618 public RemoveAdjustment(IReadOnlyDictionary rawData) { @@ -9258,8 +9312,11 @@ public override void Validate() public RemovePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public RemovePrice(RemovePrice removePrice) : base(removePrice) { } +#pragma warning restore CS8618 public RemovePrice(IReadOnlyDictionary rawData) { @@ -9326,8 +9383,11 @@ public override void Validate() public ReplaceAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) : base(replaceAdjustment) { } +#pragma warning restore CS8618 public ReplaceAdjustment(IReadOnlyDictionary rawData) { @@ -9994,8 +10054,11 @@ public override void Validate() public ReplacePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePrice(ReplacePrice replacePrice) : base(replacePrice) { } +#pragma warning restore CS8618 public ReplacePrice(IReadOnlyDictionary rawData) { @@ -13128,10 +13191,13 @@ public ReplacePricePriceBulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFilters( ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { @@ -13231,10 +13297,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData @@ -13317,10 +13386,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData @@ -13403,10 +13475,13 @@ public override void Validate() public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData @@ -14098,10 +14173,13 @@ public ReplacePricePriceTieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProration( ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { @@ -14239,10 +14317,13 @@ public override void Validate() public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig ) : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData @@ -14335,10 +14416,13 @@ public override void Validate() public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData @@ -14964,10 +15048,13 @@ public ReplacePricePriceGroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceGroupedWithMinMaxThresholds( ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData @@ -15139,10 +15226,13 @@ public override void Validate() public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -15774,10 +15864,13 @@ public ReplacePricePriceCumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceCumulativeGroupedAllocation( ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public ReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData @@ -15949,10 +16042,13 @@ public override void Validate() public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -16576,8 +16672,11 @@ public ReplacePricePricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePricePercent(ReplacePricePricePercent replacePricePricePercent) : base(replacePricePricePercent) { } +#pragma warning restore CS8618 public ReplacePricePricePercent(IReadOnlyDictionary rawData) { @@ -16703,10 +16802,13 @@ public override void Validate() public ReplacePricePricePercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePricePercentPercentConfig( ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig ) : base(replacePricePricePercentPercentConfig) { } +#pragma warning restore CS8618 public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary rawData) { @@ -17331,8 +17433,11 @@ public ReplacePricePriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceEventOutput(ReplacePricePriceEventOutput replacePricePriceEventOutput) : base(replacePricePriceEventOutput) { } +#pragma warning restore CS8618 public ReplacePricePriceEventOutput(IReadOnlyDictionary rawData) { @@ -17489,10 +17594,13 @@ public override void Validate() public ReplacePricePriceEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceEventOutputEventOutputConfig( ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig ) : base(replacePricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsResponse.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsResponse.cs index cb4442326..4bf997a47 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsResponse.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsResponse.cs @@ -43,10 +43,13 @@ public override void Validate() public SubscriptionFetchCostsResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionFetchCostsResponse( SubscriptionFetchCostsResponse subscriptionFetchCostsResponse ) : base(subscriptionFetchCostsResponse) { } +#pragma warning restore CS8618 public SubscriptionFetchCostsResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePageResponse.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePageResponse.cs index 3cefc8958..13ea7cbda 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePageResponse.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public SubscriptionFetchSchedulePageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionFetchSchedulePageResponse( SubscriptionFetchSchedulePageResponse subscriptionFetchSchedulePageResponse ) : base(subscriptionFetchSchedulePageResponse) { } +#pragma warning restore CS8618 public SubscriptionFetchSchedulePageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleResponse.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleResponse.cs index 7f2af9304..453e2b8c4 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleResponse.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleResponse.cs @@ -67,10 +67,13 @@ public override void Validate() public SubscriptionFetchScheduleResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionFetchScheduleResponse( SubscriptionFetchScheduleResponse subscriptionFetchScheduleResponse ) : base(subscriptionFetchScheduleResponse) { } +#pragma warning restore CS8618 public SubscriptionFetchScheduleResponse(IReadOnlyDictionary rawData) { @@ -150,8 +153,11 @@ public override void Validate() public Plan() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Plan(Plan plan) : base(plan) { } +#pragma warning restore CS8618 public Plan(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index 6571a67ac..f437b3cd1 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -568,8 +568,11 @@ public override void Validate() public Add() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Add(Add add) : base(add) { } +#pragma warning restore CS8618 public Add(IReadOnlyDictionary rawData) { @@ -1218,8 +1221,11 @@ public Amount() this.DiscountType = JsonSerializer.SerializeToElement("amount"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Amount(Amount amount) : base(amount) { } +#pragma warning restore CS8618 public Amount(IReadOnlyDictionary rawData) { @@ -1304,8 +1310,11 @@ public Percentage() this.DiscountType = JsonSerializer.SerializeToElement("percentage"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percentage(Percentage percentage) : base(percentage) { } +#pragma warning restore CS8618 public Percentage(IReadOnlyDictionary rawData) { @@ -1385,8 +1394,11 @@ public Usage() this.DiscountType = JsonSerializer.SerializeToElement("usage"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Usage(Usage usage) : base(usage) { } +#pragma warning restore CS8618 public Usage(IReadOnlyDictionary rawData) { @@ -1702,8 +1714,11 @@ public override void Validate() public FixedFeeQuantityTransition() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public FixedFeeQuantityTransition(FixedFeeQuantityTransition fixedFeeQuantityTransition) : base(fixedFeeQuantityTransition) { } +#pragma warning restore CS8618 public FixedFeeQuantityTransition(IReadOnlyDictionary rawData) { @@ -4632,8 +4647,11 @@ public PriceModelBulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelBulkWithFilters(PriceModelBulkWithFilters priceModelBulkWithFilters) : base(priceModelBulkWithFilters) { } +#pragma warning restore CS8618 public PriceModelBulkWithFilters(IReadOnlyDictionary rawData) { @@ -4735,10 +4753,13 @@ public override void Validate() public PriceModelBulkWithFiltersBulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelBulkWithFiltersBulkWithFiltersConfig( PriceModelBulkWithFiltersBulkWithFiltersConfig priceModelBulkWithFiltersBulkWithFiltersConfig ) : base(priceModelBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 public PriceModelBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData @@ -4819,10 +4840,13 @@ public override void Validate() public PriceModelBulkWithFiltersBulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelBulkWithFiltersBulkWithFiltersConfigFilter( PriceModelBulkWithFiltersBulkWithFiltersConfigFilter priceModelBulkWithFiltersBulkWithFiltersConfigFilter ) : base(priceModelBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 public PriceModelBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData @@ -4905,10 +4929,13 @@ public override void Validate() public PriceModelBulkWithFiltersBulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelBulkWithFiltersBulkWithFiltersConfigTier( PriceModelBulkWithFiltersBulkWithFiltersConfigTier priceModelBulkWithFiltersBulkWithFiltersConfigTier ) : base(priceModelBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 public PriceModelBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData @@ -5584,10 +5611,13 @@ public PriceModelGroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelGroupedWithMinMaxThresholds( PriceModelGroupedWithMinMaxThresholds priceModelGroupedWithMinMaxThresholds ) : base(priceModelGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public PriceModelGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -5757,10 +5787,13 @@ public override void Validate() public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base(priceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -6372,10 +6405,13 @@ public PriceModelCumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelCumulativeGroupedAllocation( PriceModelCumulativeGroupedAllocation priceModelCumulativeGroupedAllocation ) : base(priceModelCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public PriceModelCumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -6545,10 +6581,13 @@ public override void Validate() public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base(priceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -7148,8 +7187,11 @@ public PriceModelPercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelPercent(PriceModelPercent priceModelPercent) : base(priceModelPercent) { } +#pragma warning restore CS8618 public PriceModelPercent(IReadOnlyDictionary rawData) { @@ -7273,10 +7315,13 @@ public override void Validate() public PriceModelPercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelPercentPercentConfig( PriceModelPercentPercentConfig priceModelPercentPercentConfig ) : base(priceModelPercentPercentConfig) { } +#pragma warning restore CS8618 public PriceModelPercentPercentConfig(IReadOnlyDictionary rawData) { @@ -7882,8 +7927,11 @@ public PriceModelEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelEventOutput(PriceModelEventOutput priceModelEventOutput) : base(priceModelEventOutput) { } +#pragma warning restore CS8618 public PriceModelEventOutput(IReadOnlyDictionary rawData) { @@ -8039,10 +8087,13 @@ public override void Validate() public PriceModelEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelEventOutputEventOutputConfig( PriceModelEventOutputEventOutputConfig priceModelEventOutputEventOutputConfig ) : base(priceModelEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public PriceModelEventOutputEventOutputConfig(IReadOnlyDictionary rawData) { @@ -8452,10 +8503,13 @@ public override void Validate() public SubscriptionPriceIntervalsParamsAddAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionPriceIntervalsParamsAddAdjustment( SubscriptionPriceIntervalsParamsAddAdjustment subscriptionPriceIntervalsParamsAddAdjustment ) : base(subscriptionPriceIntervalsParamsAddAdjustment) { } +#pragma warning restore CS8618 public SubscriptionPriceIntervalsParamsAddAdjustment( IReadOnlyDictionary rawData @@ -9693,8 +9747,11 @@ public override void Validate() public Edit() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Edit(Edit edit) : base(edit) { } +#pragma warning restore CS8618 public Edit(IReadOnlyDictionary rawData) { @@ -10015,10 +10072,13 @@ public override void Validate() public EditFixedFeeQuantityTransition() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EditFixedFeeQuantityTransition( EditFixedFeeQuantityTransition editFixedFeeQuantityTransition ) : base(editFixedFeeQuantityTransition) { } +#pragma warning restore CS8618 public EditFixedFeeQuantityTransition(IReadOnlyDictionary rawData) { @@ -10362,8 +10422,11 @@ public override void Validate() public EditAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EditAdjustment(EditAdjustment editAdjustment) : base(editAdjustment) { } +#pragma warning restore CS8618 public EditAdjustment(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs index f17728688..1605b646e 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -854,10 +854,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddAdjustment( SubscriptionSchedulePlanChangeParamsAddAdjustment subscriptionSchedulePlanChangeParamsAddAdjustment ) : base(subscriptionSchedulePlanChangeParamsAddAdjustment) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddAdjustment( IReadOnlyDictionary rawData @@ -1584,10 +1587,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPrice( SubscriptionSchedulePlanChangeParamsAddPrice subscriptionSchedulePlanChangeParamsAddPrice ) : base(subscriptionSchedulePlanChangeParamsAddPrice) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPrice( IReadOnlyDictionary rawData @@ -4805,10 +4811,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters( SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters( IReadOnlyDictionary rawData @@ -4915,12 +4924,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig( SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig subscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData @@ -5008,12 +5020,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter( SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter subscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData @@ -5101,12 +5116,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier( SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData @@ -5833,10 +5851,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( IReadOnlyDictionary rawData @@ -5997,12 +6018,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData @@ -6099,12 +6123,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData @@ -6748,10 +6775,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresho this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData @@ -6946,12 +6976,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -7595,10 +7628,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocat this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData @@ -7793,12 +7829,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -8433,10 +8472,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent ) : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( IReadOnlyDictionary rawData @@ -8574,10 +8616,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig ) : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( IReadOnlyDictionary rawData @@ -9224,10 +9269,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( IReadOnlyDictionary rawData @@ -9402,10 +9450,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData @@ -9829,10 +9880,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment ) : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( IReadOnlyDictionary rawData @@ -9919,10 +9973,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsRemovePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsRemovePrice( SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice ) : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsRemovePrice( IReadOnlyDictionary rawData @@ -10002,10 +10059,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplaceAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment ) : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( IReadOnlyDictionary rawData @@ -10710,10 +10770,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePrice( SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice ) : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePrice( IReadOnlyDictionary rawData @@ -13943,10 +14006,13 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters ) : base(subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( IReadOnlyDictionary rawData @@ -14056,12 +14122,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig ) : base( subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData @@ -14149,12 +14218,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base( subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData @@ -14242,12 +14314,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) : base( subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData @@ -14974,10 +15049,13 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration ) : base(subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( IReadOnlyDictionary rawData @@ -15140,12 +15218,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig ) : base( subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData @@ -15242,12 +15323,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier ) : base( subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData @@ -15891,10 +15975,13 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds ) : base(subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData @@ -16089,12 +16176,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -16738,10 +16828,13 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation ) : base(subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData @@ -16936,12 +17029,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base( subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -17576,10 +17672,13 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePricePercent( SubscriptionSchedulePlanChangeParamsReplacePricePricePercent subscriptionSchedulePlanChangeParamsReplacePricePricePercent ) : base(subscriptionSchedulePlanChangeParamsReplacePricePricePercent) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePricePercent( IReadOnlyDictionary rawData @@ -17723,10 +17822,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePricePercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePricePercentPercentConfig( SubscriptionSchedulePlanChangeParamsReplacePricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsReplacePricePricePercentPercentConfig ) : base(subscriptionSchedulePlanChangeParamsReplacePricePricePercentPercentConfig) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePricePercentPercentConfig( IReadOnlyDictionary rawData @@ -18377,10 +18479,13 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput( SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput subscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput ) : base(subscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput( IReadOnlyDictionary rawData @@ -18557,11 +18662,14 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputEventOutputConfig( SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputEventOutputConfig ) : base(subscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Subscriptions/SubscriptionSubscriptions.cs b/src/Orb/Models/Subscriptions/SubscriptionSubscriptions.cs index fef7f1f21..adee2b0a0 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSubscriptions.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSubscriptions.cs @@ -51,8 +51,11 @@ public override void Validate() public SubscriptionSubscriptions() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSubscriptions(SubscriptionSubscriptions subscriptionSubscriptions) : base(subscriptionSubscriptions) { } +#pragma warning restore CS8618 public SubscriptionSubscriptions(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionUsage.cs b/src/Orb/Models/Subscriptions/SubscriptionUsage.cs index 4380c2c61..0177eb7d4 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUsage.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUsage.cs @@ -288,8 +288,11 @@ public override void Validate() public UngroupedSubscriptionUsage() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UngroupedSubscriptionUsage(UngroupedSubscriptionUsage ungroupedSubscriptionUsage) : base(ungroupedSubscriptionUsage) { } +#pragma warning restore CS8618 public UngroupedSubscriptionUsage(IReadOnlyDictionary rawData) { @@ -380,8 +383,11 @@ public override void Validate() public Data() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Data(Data data) : base(data) { } +#pragma warning restore CS8618 public Data(IReadOnlyDictionary rawData) { @@ -442,8 +448,11 @@ public override void Validate() public BillableMetric() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillableMetric(BillableMetric billableMetric) : base(billableMetric) { } +#pragma warning restore CS8618 public BillableMetric(IReadOnlyDictionary rawData) { @@ -515,8 +524,11 @@ public override void Validate() public DataUsage() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DataUsage(DataUsage dataUsage) : base(dataUsage) { } +#pragma warning restore CS8618 public DataUsage(IReadOnlyDictionary rawData) { @@ -634,8 +646,11 @@ public override void Validate() public GroupedSubscriptionUsage() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedSubscriptionUsage(GroupedSubscriptionUsage groupedSubscriptionUsage) : base(groupedSubscriptionUsage) { } +#pragma warning restore CS8618 public GroupedSubscriptionUsage(IReadOnlyDictionary rawData) { @@ -745,8 +760,11 @@ public override void Validate() public GroupedSubscriptionUsageData() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedSubscriptionUsageData(GroupedSubscriptionUsageData groupedSubscriptionUsageData) : base(groupedSubscriptionUsageData) { } +#pragma warning restore CS8618 public GroupedSubscriptionUsageData(IReadOnlyDictionary rawData) { @@ -815,10 +833,13 @@ public override void Validate() public GroupedSubscriptionUsageDataBillableMetric() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedSubscriptionUsageDataBillableMetric( GroupedSubscriptionUsageDataBillableMetric groupedSubscriptionUsageDataBillableMetric ) : base(groupedSubscriptionUsageDataBillableMetric) { } +#pragma warning restore CS8618 public GroupedSubscriptionUsageDataBillableMetric( IReadOnlyDictionary rawData @@ -885,8 +906,11 @@ public override void Validate() public MetricGroup() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricGroup(MetricGroup metricGroup) : base(metricGroup) { } +#pragma warning restore CS8618 public MetricGroup(IReadOnlyDictionary rawData) { @@ -963,10 +987,13 @@ public override void Validate() public GroupedSubscriptionUsageDataUsage() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedSubscriptionUsageDataUsage( GroupedSubscriptionUsageDataUsage groupedSubscriptionUsageDataUsage ) : base(groupedSubscriptionUsageDataUsage) { } +#pragma warning restore CS8618 public GroupedSubscriptionUsageDataUsage(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/TaxAmount.cs b/src/Orb/Models/TaxAmount.cs index 02bb2eb00..71f52d1e1 100644 --- a/src/Orb/Models/TaxAmount.cs +++ b/src/Orb/Models/TaxAmount.cs @@ -59,8 +59,11 @@ public override void Validate() public TaxAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TaxAmount(TaxAmount taxAmount) : base(taxAmount) { } +#pragma warning restore CS8618 public TaxAmount(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/TierSubLineItem.cs b/src/Orb/Models/TierSubLineItem.cs index d8fcf62f5..dbe012e74 100644 --- a/src/Orb/Models/TierSubLineItem.cs +++ b/src/Orb/Models/TierSubLineItem.cs @@ -88,8 +88,11 @@ public override void Validate() public TierSubLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TierSubLineItem(TierSubLineItem tierSubLineItem) : base(tierSubLineItem) { } +#pragma warning restore CS8618 public TierSubLineItem(IReadOnlyDictionary rawData) { @@ -161,8 +164,11 @@ public override void Validate() public TierConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TierConfig(TierConfig tierConfig) : base(tierConfig) { } +#pragma warning restore CS8618 public TierConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/TieredConfig.cs b/src/Orb/Models/TieredConfig.cs index cc3cf9db2..a3d8c3f6d 100644 --- a/src/Orb/Models/TieredConfig.cs +++ b/src/Orb/Models/TieredConfig.cs @@ -66,8 +66,11 @@ public override void Validate() public TieredConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredConfig(TieredConfig tieredConfig) : base(tieredConfig) { } +#pragma warning restore CS8618 public TieredConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/TopLevel/TopLevelPingResponse.cs b/src/Orb/Models/TopLevel/TopLevelPingResponse.cs index 65b596de4..4cd15da59 100644 --- a/src/Orb/Models/TopLevel/TopLevelPingResponse.cs +++ b/src/Orb/Models/TopLevel/TopLevelPingResponse.cs @@ -28,8 +28,11 @@ public override void Validate() public TopLevelPingResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopLevelPingResponse(TopLevelPingResponse topLevelPingResponse) : base(topLevelPingResponse) { } +#pragma warning restore CS8618 public TopLevelPingResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/TrialDiscount.cs b/src/Orb/Models/TrialDiscount.cs index b3a6ba057..aa9e36783 100644 --- a/src/Orb/Models/TrialDiscount.cs +++ b/src/Orb/Models/TrialDiscount.cs @@ -116,8 +116,11 @@ public override void Validate() public TrialDiscount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TrialDiscount(TrialDiscount trialDiscount) : base(trialDiscount) { } +#pragma warning restore CS8618 public TrialDiscount(IReadOnlyDictionary rawData) { @@ -256,8 +259,11 @@ public override void Validate() public TrialDiscountFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TrialDiscountFilter(TrialDiscountFilter trialDiscountFilter) : base(trialDiscountFilter) { } +#pragma warning restore CS8618 public TrialDiscountFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/UnitConfig.cs b/src/Orb/Models/UnitConfig.cs index 55bd06374..9075bb751 100644 --- a/src/Orb/Models/UnitConfig.cs +++ b/src/Orb/Models/UnitConfig.cs @@ -56,8 +56,11 @@ public override void Validate() public UnitConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitConfig(UnitConfig unitConfig) : base(unitConfig) { } +#pragma warning restore CS8618 public UnitConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/UsageDiscount.cs b/src/Orb/Models/UsageDiscount.cs index dea9cd1d7..5682055ec 100644 --- a/src/Orb/Models/UsageDiscount.cs +++ b/src/Orb/Models/UsageDiscount.cs @@ -103,8 +103,11 @@ public override void Validate() public UsageDiscount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UsageDiscount(UsageDiscount usageDiscount) : base(usageDiscount) { } +#pragma warning restore CS8618 public UsageDiscount(IReadOnlyDictionary rawData) { @@ -236,8 +239,11 @@ public override void Validate() public UsageDiscountFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UsageDiscountFilter(UsageDiscountFilter usageDiscountFilter) : base(usageDiscountFilter) { } +#pragma warning restore CS8618 public UsageDiscountFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/UsageDiscountInterval.cs b/src/Orb/Models/UsageDiscountInterval.cs index 720b7e1a9..26ffe421f 100644 --- a/src/Orb/Models/UsageDiscountInterval.cs +++ b/src/Orb/Models/UsageDiscountInterval.cs @@ -123,8 +123,11 @@ public override void Validate() public UsageDiscountInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UsageDiscountInterval(UsageDiscountInterval usageDiscountInterval) : base(usageDiscountInterval) { } +#pragma warning restore CS8618 public UsageDiscountInterval(IReadOnlyDictionary rawData) { @@ -262,8 +265,11 @@ public override void Validate() public UsageDiscountIntervalFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UsageDiscountIntervalFilter(UsageDiscountIntervalFilter usageDiscountIntervalFilter) : base(usageDiscountIntervalFilter) { } +#pragma warning restore CS8618 public UsageDiscountIntervalFilter(IReadOnlyDictionary rawData) { From 3f5afb6e4e6d0c32a52e82c68c219391a09a0313 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 18:24:46 +0000 Subject: [PATCH 09/39] chore: change visibility of QueryString() and AddDefaultHeaders --- src/Orb/Core/ParamsBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Orb/Core/ParamsBase.cs b/src/Orb/Core/ParamsBase.cs index e82921642..6554ac027 100644 --- a/src/Orb/Core/ParamsBase.cs +++ b/src/Orb/Core/ParamsBase.cs @@ -151,7 +151,7 @@ JsonElement element } } - protected string QueryString(ClientOptions options) + internal string QueryString(ClientOptions options) { NameValueCollection collection = []; foreach (var item in this.RawQueryData) @@ -184,7 +184,7 @@ protected string QueryString(ClientOptions options) return null; } - protected static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions options) + internal static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions options) { foreach (var header in defaultHeaders) { From fed62bbc34caf8266c8c6b7a6646754677d45637 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 18:36:24 +0000 Subject: [PATCH 10/39] feat(client): add `ToString` and `Equals` methods --- src/Orb/Core/ClientOptions.cs | 2 +- src/Orb/Core/HttpRequest.cs | 15 +++++++++++++++ src/Orb/Core/HttpResponse.cs | 14 ++++++++++++++ src/Orb/Models/Alerts/AlertListPage.cs | 13 +++++++++++++ src/Orb/Models/Coupons/CouponListPage.cs | 13 +++++++++++++ .../Coupons/Subscriptions/SubscriptionListPage.cs | 13 +++++++++++++ src/Orb/Models/CreditNotes/CreditNoteListPage.cs | 13 +++++++++++++ .../BalanceTransactionListPage.cs | 13 +++++++++++++ .../Credits/CreditListByExternalIDPage.cs | 13 +++++++++++++ .../Models/Customers/Credits/CreditListPage.cs | 13 +++++++++++++ .../Credits/Ledger/LedgerListByExternalIDPage.cs | 13 +++++++++++++ .../Customers/Credits/Ledger/LedgerListPage.cs | 13 +++++++++++++ .../Credits/TopUps/TopUpListByExternalIDPage.cs | 13 +++++++++++++ .../Customers/Credits/TopUps/TopUpListPage.cs | 13 +++++++++++++ src/Orb/Models/Customers/CustomerListPage.cs | 13 +++++++++++++ .../DimensionalPriceGroupListPage.cs | 13 +++++++++++++ .../Models/Events/Backfills/BackfillListPage.cs | 13 +++++++++++++ src/Orb/Models/Invoices/InvoiceListPage.cs | 13 +++++++++++++ src/Orb/Models/Invoices/InvoiceListSummaryPage.cs | 13 +++++++++++++ src/Orb/Models/Items/ItemListPage.cs | 13 +++++++++++++ src/Orb/Models/Metrics/MetricListPage.cs | 13 +++++++++++++ .../Models/Plans/Migrations/MigrationListPage.cs | 13 +++++++++++++ src/Orb/Models/Plans/PlanListPage.cs | 13 +++++++++++++ src/Orb/Models/Prices/PriceListPage.cs | 13 +++++++++++++ .../SubscriptionChangeListPage.cs | 13 +++++++++++++ .../SubscriptionFetchSchedulePage.cs | 13 +++++++++++++ .../Models/Subscriptions/SubscriptionListPage.cs | 13 +++++++++++++ 27 files changed, 342 insertions(+), 1 deletion(-) diff --git a/src/Orb/Core/ClientOptions.cs b/src/Orb/Core/ClientOptions.cs index 1e8e79617..2799c8d49 100644 --- a/src/Orb/Core/ClientOptions.cs +++ b/src/Orb/Core/ClientOptions.cs @@ -7,7 +7,7 @@ namespace Orb.Core; /// /// A class representing the SDK client configuration. /// -public struct ClientOptions() +public record struct ClientOptions() { /// /// The default value used for . diff --git a/src/Orb/Core/HttpRequest.cs b/src/Orb/Core/HttpRequest.cs index 4bc2ce98d..ccfcbfd5b 100644 --- a/src/Orb/Core/HttpRequest.cs +++ b/src/Orb/Core/HttpRequest.cs @@ -8,4 +8,19 @@ public sealed class HttpRequest

public required HttpMethod Method { get; init; } public required P Params { get; init; } + + public override string ToString() => + string.Format("Method: {0}\n{1}", this.Method.ToString(), this.Params.ToString()); + + public override bool Equals(object? obj) + { + if (obj is not HttpRequest

other) + { + return false; + } + + return this.Method.Equals(other.Method) && this.Params.Equals(other.Params); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Core/HttpResponse.cs b/src/Orb/Core/HttpResponse.cs index 941a42d67..82920bb07 100644 --- a/src/Orb/Core/HttpResponse.cs +++ b/src/Orb/Core/HttpResponse.cs @@ -39,6 +39,20 @@ public bool TryGetHeaderValues( [NotNullWhen(true)] out IEnumerable? values ) => RawMessage.Headers.TryGetValues(name, out values); + public sealed override string ToString() => this.RawMessage.ToString(); + + public override bool Equals(object? obj) + { + if (obj is not global::Orb.Core.HttpResponse other) + { + return false; + } + + return this.RawMessage.Equals(other.RawMessage); + } + + public override int GetHashCode() => this.RawMessage.GetHashCode(); + public async Task Deserialize(Threading::CancellationToken cancellationToken = default) { using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource( diff --git a/src/Orb/Models/Alerts/AlertListPage.cs b/src/Orb/Models/Alerts/AlertListPage.cs index a7a6e9338..ff715af9b 100644 --- a/src/Orb/Models/Alerts/AlertListPage.cs +++ b/src/Orb/Models/Alerts/AlertListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,4 +64,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not AlertListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Coupons/CouponListPage.cs b/src/Orb/Models/Coupons/CouponListPage.cs index 3febee959..bb70cdeaa 100644 --- a/src/Orb/Models/Coupons/CouponListPage.cs +++ b/src/Orb/Models/Coupons/CouponListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,4 +64,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not CouponListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs index 7220cf504..c1aaa682f 100644 --- a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs +++ b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -65,4 +66,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not SubscriptionListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/CreditNotes/CreditNoteListPage.cs b/src/Orb/Models/CreditNotes/CreditNoteListPage.cs index 8e0ebe1c3..26da4e4b6 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteListPage.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not CreditNoteListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs index 01a438acc..06faff421 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -66,4 +67,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not BalanceTransactionListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs index cf2bb99fa..12da703c9 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -66,4 +67,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not CreditListByExternalIDPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/CreditListPage.cs b/src/Orb/Models/Customers/Credits/CreditListPage.cs index 0e3c9b0d5..3826d7ee9 100644 --- a/src/Orb/Models/Customers/Credits/CreditListPage.cs +++ b/src/Orb/Models/Customers/Credits/CreditListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not CreditListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs index f4ed0b2ba..6a2506e05 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -66,4 +67,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not LedgerListByExternalIDPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs index 2fd61302a..8c1fefdf3 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not LedgerListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs index 78aa63b2c..2de906be9 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not TopUpListByExternalIDPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs index e35ea6aed..55438d709 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not TopUpListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/CustomerListPage.cs b/src/Orb/Models/Customers/CustomerListPage.cs index 994b7ca0a..f2ab7ea02 100644 --- a/src/Orb/Models/Customers/CustomerListPage.cs +++ b/src/Orb/Models/Customers/CustomerListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,4 +64,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not CustomerListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs index cf31718c3..62831e002 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -66,4 +67,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not DimensionalPriceGroupListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Events/Backfills/BackfillListPage.cs b/src/Orb/Models/Events/Backfills/BackfillListPage.cs index 484a2f953..b8f3d9881 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListPage.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not BackfillListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Invoices/InvoiceListPage.cs b/src/Orb/Models/Invoices/InvoiceListPage.cs index d663b4499..a60ce1e17 100644 --- a/src/Orb/Models/Invoices/InvoiceListPage.cs +++ b/src/Orb/Models/Invoices/InvoiceListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,4 +64,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not InvoiceListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs b/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs index 1ee08853d..0f3108b6d 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not InvoiceListSummaryPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Items/ItemListPage.cs b/src/Orb/Models/Items/ItemListPage.cs index a336efff7..01dfc62f2 100644 --- a/src/Orb/Models/Items/ItemListPage.cs +++ b/src/Orb/Models/Items/ItemListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,4 +64,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not ItemListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Metrics/MetricListPage.cs b/src/Orb/Models/Metrics/MetricListPage.cs index 9cdc0abd1..718def11c 100644 --- a/src/Orb/Models/Metrics/MetricListPage.cs +++ b/src/Orb/Models/Metrics/MetricListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not MetricListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Plans/Migrations/MigrationListPage.cs b/src/Orb/Models/Plans/Migrations/MigrationListPage.cs index 5b715d8e1..f6bf5e22d 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListPage.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,4 +65,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not MigrationListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Plans/PlanListPage.cs b/src/Orb/Models/Plans/PlanListPage.cs index 89d2daa30..a8ff248d2 100644 --- a/src/Orb/Models/Plans/PlanListPage.cs +++ b/src/Orb/Models/Plans/PlanListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,4 +64,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not PlanListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Prices/PriceListPage.cs b/src/Orb/Models/Prices/PriceListPage.cs index efb748688..51d3b5a00 100644 --- a/src/Orb/Models/Prices/PriceListPage.cs +++ b/src/Orb/Models/Prices/PriceListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -65,4 +66,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not PriceListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs index 7eeed711c..d231fcbc3 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -66,4 +67,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not SubscriptionChangeListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs index 7c1830f3a..ab5613970 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -67,4 +68,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not SubscriptionFetchSchedulePage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Subscriptions/SubscriptionListPage.cs b/src/Orb/Models/Subscriptions/SubscriptionListPage.cs index d905b0f4f..27d1302eb 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionListPage.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,4 +64,16 @@ public void Validate() public override string ToString() => JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not SubscriptionListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } From 2cd2dd8f519176f3618044ca6d4641e678af001b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 19:25:20 +0000 Subject: [PATCH 11/39] feat(api): api update --- .stats.yml | 4 +- src/Orb.Tests/Models/CustomerTaxIDTest.cs | 2 + .../Models/ChangedSubscriptionResources.cs | 51 ++++++++++--------- src/Orb/Models/CustomerTaxID.cs | 51 ++++++++++--------- src/Orb/Models/Customers/Customer.cs | 51 ++++++++++--------- .../Models/Customers/CustomerCreateParams.cs | 51 ++++++++++--------- .../CustomerUpdateByExternalIDParams.cs | 51 ++++++++++--------- .../Models/Customers/CustomerUpdateParams.cs | 51 ++++++++++--------- src/Orb/Models/Invoice.cs | 51 ++++++++++--------- .../Invoices/InvoiceFetchUpcomingResponse.cs | 51 ++++++++++--------- .../Invoices/InvoiceListSummaryResponse.cs | 51 ++++++++++--------- 11 files changed, 239 insertions(+), 226 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1f41e32fa..e572dc254 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-6017828d1287c194d4d7759dc5b5410225ab58af66ff8605315f70f5e623b82d.yml -openapi_spec_hash: 4390eaf377258fcd7db1dbc073a2c23f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-9f1a41612765cb08d100b2c9e85080e93306e8d0942d535f16052c3eb18d9b8b.yml +openapi_spec_hash: 6dd28f36adc7e7d6a9245585eaf9b9c1 config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/src/Orb.Tests/Models/CustomerTaxIDTest.cs b/src/Orb.Tests/Models/CustomerTaxIDTest.cs index 11f10dfe3..3d62e169b 100644 --- a/src/Orb.Tests/Models/CustomerTaxIDTest.cs +++ b/src/Orb.Tests/Models/CustomerTaxIDTest.cs @@ -464,6 +464,7 @@ public class CustomerTaxIDTypeTest : TestBase [InlineData(CustomerTaxIDType.OmVat)] [InlineData(CustomerTaxIDType.PeRuc)] [InlineData(CustomerTaxIDType.PhTin)] + [InlineData(CustomerTaxIDType.PlNip)] [InlineData(CustomerTaxIDType.RoTin)] [InlineData(CustomerTaxIDType.RsPib)] [InlineData(CustomerTaxIDType.RuInn)] @@ -594,6 +595,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerTaxIDType.OmVat)] [InlineData(CustomerTaxIDType.PeRuc)] [InlineData(CustomerTaxIDType.PhTin)] + [InlineData(CustomerTaxIDType.PlNip)] [InlineData(CustomerTaxIDType.RoTin)] [InlineData(CustomerTaxIDType.RsPib)] [InlineData(CustomerTaxIDType.RuInn)] diff --git a/src/Orb/Models/ChangedSubscriptionResources.cs b/src/Orb/Models/ChangedSubscriptionResources.cs index 351460a2d..c428a3143 100644 --- a/src/Orb/Models/ChangedSubscriptionResources.cs +++ b/src/Orb/Models/ChangedSubscriptionResources.cs @@ -355,31 +355,32 @@ public required IReadOnlyList CustomerBalanceTransac /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///

public required CustomerTaxID? CustomerTaxID { diff --git a/src/Orb/Models/CustomerTaxID.cs b/src/Orb/Models/CustomerTaxID.cs index 6fa3b8bd5..86f7e3812 100644 --- a/src/Orb/Models/CustomerTaxID.cs +++ b/src/Orb/Models/CustomerTaxID.cs @@ -84,30 +84,30 @@ namespace Orb.Models; /// Number | | Norway | `no_voec` | Norwegian VAT on e-commerce Number | | Oman | /// `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian RUC Number | | Philippines /// | `ph_tin` | Philippines Tax Identification Number | | Poland | `eu_vat` | European -/// VAT Number | | Portugal | `eu_vat` | European VAT Number | | Romania | `eu_vat` -/// | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number | | Russia -/// | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | | Saudi Arabia -/// | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal NINEA Number -/// | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` | Singaporean -/// GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia | `eu_vat` | European -/// VAT Number | | Slovenia | `eu_vat` | European VAT Number | | Slovenia | `si_tin` -/// | Slovenia Tax Number (davčna številka) | | South Africa | `za_vat` | South African -/// VAT Number | | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish -/// NIF Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT -/// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` | European -/// VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number | | Switzerland -/// | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | -/// Tajikistan | `tj_tin` | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` -/// | Tanzania VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` -/// | Turkish Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification -/// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` -/// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom VAT -/// Number | | United States | `us_ein` | United States EIN | | Uruguay | `uy_ruc` -/// | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN Number | | -/// Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` | Venezuelan -/// RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` -/// | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification -/// Number |
+/// VAT Number | | Poland | `pl_nip` | Polish Tax ID Number | | Portugal | `eu_vat` +/// | European VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania +/// | `ro_tin` | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia +/// | `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal +/// | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number +/// | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` | Singaporean +/// UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European +/// VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | +/// South Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` +/// | Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF +/// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` | +/// Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland +/// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland +/// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` | +/// Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania VAT Number +/// | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification +/// Number | | Uganda | `ug_tin` | Uganda Tax Identification Number | | Ukraine | +/// `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates +/// TRN | | United Kingdom | `gb_vat` | United Kingdom VAT Number | | United States +/// | `us_ein` | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | +/// | Uzbekistan | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan +/// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | `vn_tin` +/// | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification Number +/// | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | ///
[JsonConverter(typeof(JsonModelConverter))] public sealed record class CustomerTaxID : JsonModel @@ -641,6 +641,7 @@ public enum CustomerTaxIDType OmVat, PeRuc, PhTin, + PlNip, RoTin, RsPib, RuInn, @@ -763,6 +764,7 @@ JsonSerializerOptions options "om_vat" => CustomerTaxIDType.OmVat, "pe_ruc" => CustomerTaxIDType.PeRuc, "ph_tin" => CustomerTaxIDType.PhTin, + "pl_nip" => CustomerTaxIDType.PlNip, "ro_tin" => CustomerTaxIDType.RoTin, "rs_pib" => CustomerTaxIDType.RsPib, "ru_inn" => CustomerTaxIDType.RuInn, @@ -887,6 +889,7 @@ JsonSerializerOptions options CustomerTaxIDType.OmVat => "om_vat", CustomerTaxIDType.PeRuc => "pe_ruc", CustomerTaxIDType.PhTin => "ph_tin", + CustomerTaxIDType.PlNip => "pl_nip", CustomerTaxIDType.RoTin => "ro_tin", CustomerTaxIDType.RsPib => "rs_pib", CustomerTaxIDType.RuInn => "ru_inn", diff --git a/src/Orb/Models/Customers/Customer.cs b/src/Orb/Models/Customers/Customer.cs index d4cdfef9e..7b66b3d65 100644 --- a/src/Orb/Models/Customers/Customer.cs +++ b/src/Orb/Models/Customers/Customer.cs @@ -350,31 +350,32 @@ public required Address? ShippingAddress /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///
public required CustomerTaxID? TaxID { diff --git a/src/Orb/Models/Customers/CustomerCreateParams.cs b/src/Orb/Models/Customers/CustomerCreateParams.cs index 75165aaee..9a0598c2b 100644 --- a/src/Orb/Models/Customers/CustomerCreateParams.cs +++ b/src/Orb/Models/Customers/CustomerCreateParams.cs @@ -368,31 +368,32 @@ public TaxConfiguration? TaxConfiguration /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///
public CustomerTaxID? TaxID { diff --git a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index 71db0fde8..521bc0b76 100644 --- a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs @@ -369,31 +369,32 @@ public CustomerUpdateByExternalIDParamsTaxConfiguration? TaxConfiguration /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///
public CustomerTaxID? TaxID { diff --git a/src/Orb/Models/Customers/CustomerUpdateParams.cs b/src/Orb/Models/Customers/CustomerUpdateParams.cs index d46922d5c..3b24c01f4 100644 --- a/src/Orb/Models/Customers/CustomerUpdateParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateParams.cs @@ -370,31 +370,32 @@ public CustomerUpdateParamsTaxConfiguration? TaxConfiguration /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///
public CustomerTaxID? TaxID { diff --git a/src/Orb/Models/Invoice.cs b/src/Orb/Models/Invoice.cs index ac6104927..19746afef 100644 --- a/src/Orb/Models/Invoice.cs +++ b/src/Orb/Models/Invoice.cs @@ -218,31 +218,32 @@ public required IReadOnlyList CustomerBalance /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///
public required CustomerTaxID? CustomerTaxID { diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs index 952adaca7..65b1aa1d2 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs @@ -211,31 +211,32 @@ public required IReadOnlyList CustomerBalanceTransac /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///
public required CustomerTaxID? CustomerTaxID { diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs b/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs index dc1187a9e..3d62887b4 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs @@ -218,31 +218,32 @@ public required IReadOnlyList + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///
public required CustomerTaxID? CustomerTaxID { From 2a92abb2b86492e4018b9c8fa5d75ad9486d55fc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 19:34:10 +0000 Subject: [PATCH 12/39] chore(internal): improve HttpResponse qualification --- src/Orb/Core/HttpResponse.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Orb/Core/HttpResponse.cs b/src/Orb/Core/HttpResponse.cs index 82920bb07..36369c9ab 100644 --- a/src/Orb/Core/HttpResponse.cs +++ b/src/Orb/Core/HttpResponse.cs @@ -43,7 +43,7 @@ public bool TryGetHeaderValues( public override bool Equals(object? obj) { - if (obj is not global::Orb.Core.HttpResponse other) + if (obj is not HttpResponse other) { return false; } @@ -109,7 +109,7 @@ public void Dispose() } } -public sealed class HttpResponse : global::Orb.Core.HttpResponse +public sealed class HttpResponse : HttpResponse { readonly Func> _deserialize; @@ -120,7 +120,7 @@ internal HttpResponse(Func> deserialize) [SetsRequiredMembers] internal HttpResponse( - global::Orb.Core.HttpResponse response, + HttpResponse response, Func> deserialize ) : this(deserialize) @@ -139,7 +139,7 @@ public Task Deserialize(Threading::CancellationToken cancellationToken = defa } } -public sealed class StreamingHttpResponse : global::Orb.Core.HttpResponse +public sealed class StreamingHttpResponse : HttpResponse { readonly Func> _enumerate; @@ -152,7 +152,7 @@ internal StreamingHttpResponse( [SetsRequiredMembers] internal StreamingHttpResponse( - global::Orb.Core.HttpResponse response, + HttpResponse response, Func> enumerate ) : this(enumerate) From bb13041f80e071a51a8aa845c2a5b2e720e4cd75 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 21:12:24 +0000 Subject: [PATCH 13/39] fix(client): handle unions containing unknown types properly --- .../LedgerCreateEntryByExternalIDParams.cs | 10 ++++- .../Credits/Ledger/LedgerCreateEntryParams.cs | 10 ++++- .../Models/Invoices/InvoiceCreateParams.cs | 5 ++- .../Models/Invoices/InvoiceUpdateParams.cs | 10 ++++- .../Migrations/MigrationCancelResponse.cs | 5 ++- .../Plans/Migrations/MigrationListResponse.cs | 5 ++- .../Migrations/MigrationRetrieveResponse.cs | 5 ++- src/Orb/Models/Prices/EvaluatePriceGroup.cs | 4 +- .../SubscriptionPriceIntervalsParams.cs | 40 +++++++++++++++---- .../SubscriptionUpdateTrialParams.cs | 5 ++- 10 files changed, 78 insertions(+), 21 deletions(-) diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index a77c6efc9..96fce27e4 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -1705,7 +1705,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -1963,7 +1966,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index 0cedeb751..d798a398b 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -1536,7 +1536,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -1770,7 +1773,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Invoices/InvoiceCreateParams.cs b/src/Orb/Models/Invoices/InvoiceCreateParams.cs index 054c36a79..072881080 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -697,7 +697,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs index f7d4c2cbb..187f3f1d6 100644 --- a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs @@ -432,7 +432,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -664,7 +667,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs index 2b829d4a6..4c49cef0a 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs @@ -402,7 +402,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs index 7899b8fa2..9f189a3cd 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs @@ -401,7 +401,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs index 1e17e6b8f..46ea0ab86 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs @@ -372,7 +372,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Prices/EvaluatePriceGroup.cs b/src/Orb/Models/Prices/EvaluatePriceGroup.cs index e94835177..273f65273 100644 --- a/src/Orb/Models/Prices/EvaluatePriceGroup.cs +++ b/src/Orb/Models/Prices/EvaluatePriceGroup.cs @@ -356,7 +356,7 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new(JsonSerializer.Deserialize(element, options), element); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -365,7 +365,7 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new(JsonSerializer.Deserialize(element, options), element); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index f437b3cd1..1dd3bbe49 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -830,7 +830,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -1658,7 +1661,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -8795,7 +8801,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -9565,7 +9574,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -10009,7 +10021,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -10340,7 +10355,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -10696,7 +10714,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -10950,7 +10971,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs index d455a5574..4c89d33c2 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs @@ -416,7 +416,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { From f9055f0118384c77b1ef687b756e5a49f3f417dc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 29 Jan 2026 19:25:58 +0000 Subject: [PATCH 14/39] chore(internal): ignore stainless-internal artifacts --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 08a6d8081..cb0f7844e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ bin/ obj/ .vs/ .idea/ + +# do not edit! excludes generated files used internally +.artifacts/ From 563558107f3fa7d5e947ecf758875794c3e04dff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 22:01:21 +0000 Subject: [PATCH 15/39] fix(client): improve union equality method --- src/Orb/Models/AdjustmentInterval.cs | 21 +- .../Beta/BetaCreatePlanVersionParams.cs | 352 ++++++++-- .../ExternalPlanIDCreatePlanVersionParams.cs | 352 ++++++++-- src/Orb/Models/Beta/PlanVersion.cs | 21 +- .../Models/ChangedSubscriptionResources.cs | 40 +- src/Orb/Models/Coupons/Coupon.cs | 18 +- src/Orb/Models/Coupons/CouponCreateParams.cs | 18 +- .../LedgerCreateEntryByExternalIDParams.cs | 57 +- .../LedgerCreateEntryByExternalIDResponse.cs | 23 +- .../Credits/Ledger/LedgerCreateEntryParams.cs | 57 +- .../Ledger/LedgerCreateEntryResponse.cs | 23 +- .../Ledger/LedgerListByExternalIDResponse.cs | 23 +- .../Credits/Ledger/LedgerListResponse.cs | 23 +- .../Models/Customers/CustomerCreateParams.cs | 22 +- .../CustomerUpdateByExternalIDParams.cs | 22 +- .../Models/Customers/CustomerUpdateParams.cs | 22 +- src/Orb/Models/Invoice.cs | 40 +- src/Orb/Models/InvoiceLevelDiscount.cs | 19 +- .../InvoiceLineItemCreateResponse.cs | 40 +- .../Models/Invoices/InvoiceCreateParams.cs | 18 +- .../Invoices/InvoiceFetchUpcomingResponse.cs | 40 +- .../Models/Invoices/InvoiceUpdateParams.cs | 36 +- src/Orb/Models/NewFloatingBulkPrice.cs | 18 +- .../NewFloatingBulkWithProrationPrice.cs | 18 +- .../NewFloatingCumulativeGroupedBulkPrice.cs | 18 +- .../NewFloatingGroupedAllocationPrice.cs | 18 +- .../NewFloatingGroupedTieredPackagePrice.cs | 18 +- .../Models/NewFloatingGroupedTieredPrice.cs | 18 +- ...wFloatingGroupedWithMeteredMinimumPrice.cs | 20 +- ...FloatingGroupedWithProratedMinimumPrice.cs | 18 +- src/Orb/Models/NewFloatingMatrixPrice.cs | 18 +- .../NewFloatingMatrixWithAllocationPrice.cs | 18 +- .../NewFloatingMatrixWithDisplayNamePrice.cs | 18 +- .../NewFloatingMaxGroupTieredPackagePrice.cs | 18 +- .../NewFloatingMinimumCompositePrice.cs | 18 +- src/Orb/Models/NewFloatingPackagePrice.cs | 18 +- .../NewFloatingPackageWithAllocationPrice.cs | 18 +- ...ingScalableMatrixWithTieredPricingPrice.cs | 18 +- ...atingScalableMatrixWithUnitPricingPrice.cs | 18 +- .../NewFloatingThresholdTotalAmountPrice.cs | 18 +- .../Models/NewFloatingTieredPackagePrice.cs | 18 +- ...ewFloatingTieredPackageWithMinimumPrice.cs | 20 +- src/Orb/Models/NewFloatingTieredPrice.cs | 18 +- .../NewFloatingTieredWithMinimumPrice.cs | 18 +- .../NewFloatingTieredWithProrationPrice.cs | 18 +- src/Orb/Models/NewFloatingUnitPrice.cs | 18 +- .../Models/NewFloatingUnitWithPercentPrice.cs | 18 +- .../NewFloatingUnitWithProrationPrice.cs | 18 +- src/Orb/Models/NewPlanBulkPrice.cs | 18 +- .../Models/NewPlanBulkWithProrationPrice.cs | 18 +- .../NewPlanCumulativeGroupedBulkPrice.cs | 18 +- .../Models/NewPlanGroupedAllocationPrice.cs | 18 +- .../NewPlanGroupedTieredPackagePrice.cs | 18 +- src/Orb/Models/NewPlanGroupedTieredPrice.cs | 18 +- .../NewPlanGroupedWithMeteredMinimumPrice.cs | 18 +- .../NewPlanGroupedWithProratedMinimumPrice.cs | 18 +- src/Orb/Models/NewPlanMatrixPrice.cs | 18 +- .../NewPlanMatrixWithAllocationPrice.cs | 18 +- .../NewPlanMatrixWithDisplayNamePrice.cs | 18 +- .../NewPlanMaxGroupTieredPackagePrice.cs | 18 +- .../Models/NewPlanMinimumCompositePrice.cs | 18 +- src/Orb/Models/NewPlanPackagePrice.cs | 18 +- .../NewPlanPackageWithAllocationPrice.cs | 18 +- ...lanScalableMatrixWithTieredPricingPrice.cs | 18 +- ...wPlanScalableMatrixWithUnitPricingPrice.cs | 20 +- .../NewPlanThresholdTotalAmountPrice.cs | 18 +- src/Orb/Models/NewPlanTieredPackagePrice.cs | 18 +- .../NewPlanTieredPackageWithMinimumPrice.cs | 18 +- src/Orb/Models/NewPlanTieredPrice.cs | 18 +- .../Models/NewPlanTieredWithMinimumPrice.cs | 18 +- src/Orb/Models/NewPlanUnitPrice.cs | 18 +- src/Orb/Models/NewPlanUnitWithPercentPrice.cs | 18 +- .../Models/NewPlanUnitWithProrationPrice.cs | 18 +- .../Migrations/MigrationCancelResponse.cs | 19 +- .../Plans/Migrations/MigrationListResponse.cs | 19 +- .../Migrations/MigrationRetrieveResponse.cs | 19 +- src/Orb/Models/Plans/Plan.cs | 21 +- src/Orb/Models/Plans/PlanCreateParams.cs | 176 ++++- src/Orb/Models/Price.cs | 605 ++++++++++++++---- src/Orb/Models/Prices/EvaluatePriceGroup.cs | 19 +- src/Orb/Models/Prices/PriceCreateParams.cs | 137 +++- .../Prices/PriceEvaluateMultipleParams.cs | 137 +++- .../PriceEvaluatePreviewEventsParams.cs | 137 +++- src/Orb/Models/SharedDiscount.cs | 20 +- .../MutatedSubscription.cs | 19 +- .../Subscriptions/NewSubscriptionBulkPrice.cs | 18 +- .../NewSubscriptionBulkWithProrationPrice.cs | 18 +- ...wSubscriptionCumulativeGroupedBulkPrice.cs | 20 +- .../NewSubscriptionGroupedAllocationPrice.cs | 18 +- ...ewSubscriptionGroupedTieredPackagePrice.cs | 20 +- .../NewSubscriptionGroupedTieredPrice.cs | 18 +- ...scriptionGroupedWithMeteredMinimumPrice.cs | 18 +- ...criptionGroupedWithProratedMinimumPrice.cs | 18 +- .../NewSubscriptionMatrixPrice.cs | 18 +- ...ewSubscriptionMatrixWithAllocationPrice.cs | 20 +- ...wSubscriptionMatrixWithDisplayNamePrice.cs | 20 +- ...wSubscriptionMaxGroupTieredPackagePrice.cs | 20 +- .../NewSubscriptionMinimumCompositePrice.cs | 18 +- .../NewSubscriptionPackagePrice.cs | 18 +- ...wSubscriptionPackageWithAllocationPrice.cs | 20 +- ...ionScalableMatrixWithTieredPricingPrice.cs | 18 +- ...ptionScalableMatrixWithUnitPricingPrice.cs | 18 +- ...ewSubscriptionThresholdTotalAmountPrice.cs | 20 +- .../NewSubscriptionTieredPackagePrice.cs | 18 +- ...bscriptionTieredPackageWithMinimumPrice.cs | 18 +- .../NewSubscriptionTieredPrice.cs | 18 +- .../NewSubscriptionTieredWithMinimumPrice.cs | 18 +- .../Subscriptions/NewSubscriptionUnitPrice.cs | 18 +- .../NewSubscriptionUnitWithPercentPrice.cs | 18 +- .../NewSubscriptionUnitWithProrationPrice.cs | 18 +- src/Orb/Models/Subscriptions/Subscription.cs | 19 +- .../Subscriptions/SubscriptionCreateParams.cs | 352 ++++++++-- .../SubscriptionPriceIntervalsParams.cs | 321 ++++++++-- .../SubscriptionSchedulePlanChangeParams.cs | 356 +++++++++-- .../SubscriptionUpdateTrialParams.cs | 18 +- .../Models/Subscriptions/SubscriptionUsage.cs | 18 +- 116 files changed, 4075 insertions(+), 1012 deletions(-) diff --git a/src/Orb/Models/AdjustmentInterval.cs b/src/Orb/Models/AdjustmentInterval.cs index b667c2d9b..6ad1e72b5 100644 --- a/src/Orb/Models/AdjustmentInterval.cs +++ b/src/Orb/Models/AdjustmentInterval.cs @@ -495,10 +495,10 @@ public override void Validate() ); } - public virtual bool Equals(Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -507,6 +507,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + PlanPhaseUsageDiscountAdjustment _ => 0, + PlanPhaseAmountDiscountAdjustment _ => 1, + PlanPhasePercentageDiscountAdjustment _ => 2, + PlanPhaseMinimumAdjustment _ => 3, + PlanPhaseMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class AdjustmentConverter : JsonConverter diff --git a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs index 11b89c315..9eceac571 100644 --- a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs @@ -688,10 +688,10 @@ public override void Validate() ); } - public virtual bool Equals(Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -700,6 +700,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class AdjustmentConverter : JsonConverter @@ -2790,10 +2803,10 @@ public override void Validate() ); } - public virtual bool Equals(Price? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2802,6 +2815,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + TieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + NewPlanMinimumCompositePrice _ => 28, + Percent _ => 29, + EventOutput _ => 30, + _ => -1, + }; + } } sealed class PriceConverter : JsonConverter @@ -4335,10 +4387,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4347,6 +4399,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ConversionRateConfigConverter : JsonConverter @@ -5178,10 +5240,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5190,6 +5252,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithProrationConversionRateConfigConverter @@ -5973,10 +6045,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5985,6 +6057,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -6768,10 +6850,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6780,6 +6862,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class CumulativeGroupedAllocationConversionRateConfigConverter @@ -7503,10 +7595,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7515,6 +7607,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PercentConversionRateConfigConverter : JsonConverter @@ -8275,10 +8377,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8287,6 +8389,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class EventOutputConversionRateConfigConverter @@ -8946,10 +9058,10 @@ public override void Validate() ); } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8958,6 +9070,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter @@ -11134,10 +11259,10 @@ public override void Validate() ); } - public virtual bool Equals(ReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -11146,6 +11271,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + ReplacePricePriceBulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + ReplacePricePriceTieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + ReplacePricePriceCumulativeGroupedAllocation _ => 27, + NewPlanMinimumCompositePrice _ => 28, + ReplacePricePricePercent _ => 29, + ReplacePricePriceEventOutput _ => 30, + _ => -1, + }; + } } sealed class ReplacePricePriceConverter : JsonConverter @@ -12765,10 +12929,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -12777,6 +12941,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter @@ -13640,10 +13814,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -13652,6 +13826,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter @@ -14454,10 +14638,10 @@ public override void Validate() public virtual bool Equals( ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -14466,6 +14650,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -15270,10 +15464,10 @@ public override void Validate() public virtual bool Equals( ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -15282,6 +15476,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -16028,10 +16232,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePricePercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePricePercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16040,6 +16244,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePricePercentConversionRateConfigConverter @@ -16822,10 +17036,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceEventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceEventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16834,6 +17048,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceEventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index 7a7a5ce5f..847392b0b 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -690,10 +690,10 @@ public override void Validate() ); } - public virtual bool Equals(Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -702,6 +702,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class AdjustmentConverter : JsonConverter @@ -2792,10 +2805,10 @@ public override void Validate() ); } - public virtual bool Equals(Price? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2804,6 +2817,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + TieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + NewPlanMinimumCompositePrice _ => 28, + Percent _ => 29, + EventOutput _ => 30, + _ => -1, + }; + } } sealed class PriceConverter : JsonConverter @@ -4337,10 +4389,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4349,6 +4401,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ConversionRateConfigConverter : JsonConverter @@ -5180,10 +5242,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5192,6 +5254,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithProrationConversionRateConfigConverter @@ -5975,10 +6047,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5987,6 +6059,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -6770,10 +6852,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6782,6 +6864,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class CumulativeGroupedAllocationConversionRateConfigConverter @@ -7505,10 +7597,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7517,6 +7609,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PercentConversionRateConfigConverter : JsonConverter @@ -8277,10 +8379,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8289,6 +8391,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class EventOutputConversionRateConfigConverter @@ -8948,10 +9060,10 @@ public override void Validate() ); } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8960,6 +9072,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter @@ -11136,10 +11261,10 @@ public override void Validate() ); } - public virtual bool Equals(ReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -11148,6 +11273,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + ReplacePricePriceBulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + ReplacePricePriceTieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + ReplacePricePriceCumulativeGroupedAllocation _ => 27, + NewPlanMinimumCompositePrice _ => 28, + ReplacePricePricePercent _ => 29, + ReplacePricePriceEventOutput _ => 30, + _ => -1, + }; + } } sealed class ReplacePricePriceConverter : JsonConverter @@ -12767,10 +12931,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -12779,6 +12943,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter @@ -13642,10 +13816,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -13654,6 +13828,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter @@ -14456,10 +14640,10 @@ public override void Validate() public virtual bool Equals( ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -14468,6 +14652,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -15272,10 +15466,10 @@ public override void Validate() public virtual bool Equals( ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -15284,6 +15478,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -16030,10 +16234,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePricePercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePricePercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16042,6 +16246,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePricePercentConversionRateConfigConverter @@ -16824,10 +17038,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceEventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceEventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16836,6 +17050,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceEventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Beta/PlanVersion.cs b/src/Orb/Models/Beta/PlanVersion.cs index 8a17a1e38..db45b8743 100644 --- a/src/Orb/Models/Beta/PlanVersion.cs +++ b/src/Orb/Models/Beta/PlanVersion.cs @@ -552,10 +552,10 @@ public override void Validate() ); } - public virtual bool Equals(PlanVersionAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PlanVersionAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -564,6 +564,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + Models::PlanPhaseUsageDiscountAdjustment _ => 0, + Models::PlanPhaseAmountDiscountAdjustment _ => 1, + Models::PlanPhasePercentageDiscountAdjustment _ => 2, + Models::PlanPhaseMinimumAdjustment _ => 3, + Models::PlanPhaseMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class PlanVersionAdjustmentConverter : JsonConverter diff --git a/src/Orb/Models/ChangedSubscriptionResources.cs b/src/Orb/Models/ChangedSubscriptionResources.cs index c428a3143..92c8473fa 100644 --- a/src/Orb/Models/ChangedSubscriptionResources.cs +++ b/src/Orb/Models/ChangedSubscriptionResources.cs @@ -2212,10 +2212,10 @@ public override void Validate() ); } - public virtual bool Equals(LineItemAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LineItemAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2224,6 +2224,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class LineItemAdjustmentConverter : JsonConverter @@ -2625,10 +2638,10 @@ public override void Validate() ); } - public virtual bool Equals(SubLineItem? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubLineItem? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2637,6 +2650,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } sealed class SubLineItemConverter : JsonConverter diff --git a/src/Orb/Models/Coupons/Coupon.cs b/src/Orb/Models/Coupons/Coupon.cs index 719abb523..7b4a812d3 100644 --- a/src/Orb/Models/Coupons/Coupon.cs +++ b/src/Orb/Models/Coupons/Coupon.cs @@ -337,10 +337,10 @@ public override void Validate() this.Switch((percentage) => percentage.Validate(), (amount) => amount.Validate()); } - public virtual bool Equals(CouponDiscount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CouponDiscount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -349,6 +349,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + PercentageDiscount _ => 0, + AmountDiscount _ => 1, + _ => -1, + }; + } } sealed class CouponDiscountConverter : JsonConverter diff --git a/src/Orb/Models/Coupons/CouponCreateParams.cs b/src/Orb/Models/Coupons/CouponCreateParams.cs index 9c4238e24..decab9de3 100644 --- a/src/Orb/Models/Coupons/CouponCreateParams.cs +++ b/src/Orb/Models/Coupons/CouponCreateParams.cs @@ -353,10 +353,10 @@ public override void Validate() this.Switch((percentage) => percentage.Validate(), (amount) => amount.Validate()); } - public virtual bool Equals(Discount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Discount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -365,6 +365,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + Percentage _ => 0, + Amount _ => 1, + _ => -1, + }; + } } sealed class DiscountConverter : JsonConverter diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index 96fce27e4..d99c29d1f 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -656,10 +656,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerCreateEntryByExternalIDParamsBody? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerCreateEntryByExternalIDParamsBody? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -668,6 +668,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + LedgerCreateEntryByExternalIDParamsBodyIncrement _ => 0, + LedgerCreateEntryByExternalIDParamsBodyDecrement _ => 1, + LedgerCreateEntryByExternalIDParamsBodyExpirationChange _ => 2, + LedgerCreateEntryByExternalIDParamsBodyVoid _ => 3, + LedgerCreateEntryByExternalIDParamsBodyAmendment _ => 4, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyConverter @@ -1666,10 +1679,10 @@ public override void Validate() public virtual bool Equals( LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsCustomDueDate? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1678,6 +1691,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsCustomDueDateConverter @@ -1927,10 +1950,10 @@ public override void Validate() public virtual bool Equals( LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsInvoiceDate? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1939,6 +1962,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsInvoiceDateConverter diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs index e4ad57565..a825ab432 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs @@ -627,10 +627,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerCreateEntryByExternalIDResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerCreateEntryByExternalIDResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -639,6 +639,21 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + IncrementLedgerEntry _ => 0, + DecrementLedgerEntry _ => 1, + ExpirationChangeLedgerEntry _ => 2, + CreditBlockExpiryLedgerEntry _ => 3, + VoidLedgerEntry _ => 4, + VoidInitiatedLedgerEntry _ => 5, + AmendmentLedgerEntry _ => 6, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDResponseConverter diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index d798a398b..9c3b7edf4 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -603,10 +603,10 @@ public override void Validate() ); } - public virtual bool Equals(Body? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Body? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -615,6 +615,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + Increment _ => 0, + Decrement _ => 1, + ExpirationChange _ => 2, + Void _ => 3, + Amendment _ => 4, + _ => -1, + }; + } } sealed class BodyConverter : JsonConverter @@ -1498,10 +1511,10 @@ public override void Validate() } } - public virtual bool Equals(CustomDueDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomDueDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1510,6 +1523,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class CustomDueDateConverter : JsonConverter @@ -1735,10 +1758,10 @@ public override void Validate() } } - public virtual bool Equals(InvoiceDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1747,6 +1770,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceDateConverter : JsonConverter diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs index b579876c4..3c06ac95d 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs @@ -605,10 +605,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerCreateEntryResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerCreateEntryResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -617,6 +617,21 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + IncrementLedgerEntry _ => 0, + DecrementLedgerEntry _ => 1, + ExpirationChangeLedgerEntry _ => 2, + CreditBlockExpiryLedgerEntry _ => 3, + VoidLedgerEntry _ => 4, + VoidInitiatedLedgerEntry _ => 5, + AmendmentLedgerEntry _ => 6, + _ => -1, + }; + } } sealed class LedgerCreateEntryResponseConverter : JsonConverter diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs index 08954b4cd..8a656ea54 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs @@ -615,10 +615,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerListByExternalIDResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerListByExternalIDResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -627,6 +627,21 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + IncrementLedgerEntry _ => 0, + DecrementLedgerEntry _ => 1, + ExpirationChangeLedgerEntry _ => 2, + CreditBlockExpiryLedgerEntry _ => 3, + VoidLedgerEntry _ => 4, + VoidInitiatedLedgerEntry _ => 5, + AmendmentLedgerEntry _ => 6, + _ => -1, + }; + } } sealed class LedgerListByExternalIDResponseConverter : JsonConverter diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs index 840a5e070..871f87d03 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs @@ -599,10 +599,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerListResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerListResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -611,6 +611,21 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + IncrementLedgerEntry _ => 0, + DecrementLedgerEntry _ => 1, + ExpirationChangeLedgerEntry _ => 2, + CreditBlockExpiryLedgerEntry _ => 3, + VoidLedgerEntry _ => 4, + VoidInitiatedLedgerEntry _ => 5, + AmendmentLedgerEntry _ => 6, + _ => -1, + }; + } } sealed class LedgerListResponseConverter : JsonConverter diff --git a/src/Orb/Models/Customers/CustomerCreateParams.cs b/src/Orb/Models/Customers/CustomerCreateParams.cs index 9a0598c2b..8b96bcb3f 100644 --- a/src/Orb/Models/Customers/CustomerCreateParams.cs +++ b/src/Orb/Models/Customers/CustomerCreateParams.cs @@ -1163,10 +1163,10 @@ public override void Validate() ); } - public virtual bool Equals(TaxConfiguration? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TaxConfiguration? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1175,6 +1175,20 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewAvalaraTaxConfiguration _ => 0, + NewTaxJarConfiguration _ => 1, + NewSphereConfiguration _ => 2, + Numeral _ => 3, + Anrok _ => 4, + Stripe _ => 5, + _ => -1, + }; + } } sealed class TaxConfigurationConverter : JsonConverter diff --git a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index 521bc0b76..c8ed516c2 100644 --- a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs @@ -1249,10 +1249,10 @@ public override void Validate() ); } - public virtual bool Equals(CustomerUpdateByExternalIDParamsTaxConfiguration? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomerUpdateByExternalIDParamsTaxConfiguration? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1261,6 +1261,20 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewAvalaraTaxConfiguration _ => 0, + NewTaxJarConfiguration _ => 1, + NewSphereConfiguration _ => 2, + CustomerUpdateByExternalIDParamsTaxConfigurationNumeral _ => 3, + CustomerUpdateByExternalIDParamsTaxConfigurationAnrok _ => 4, + CustomerUpdateByExternalIDParamsTaxConfigurationStripe _ => 5, + _ => -1, + }; + } } sealed class CustomerUpdateByExternalIDParamsTaxConfigurationConverter diff --git a/src/Orb/Models/Customers/CustomerUpdateParams.cs b/src/Orb/Models/Customers/CustomerUpdateParams.cs index 3b24c01f4..a9ec73d8e 100644 --- a/src/Orb/Models/Customers/CustomerUpdateParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateParams.cs @@ -1236,10 +1236,10 @@ public override void Validate() ); } - public virtual bool Equals(CustomerUpdateParamsTaxConfiguration? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomerUpdateParamsTaxConfiguration? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1248,6 +1248,20 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewAvalaraTaxConfiguration _ => 0, + NewTaxJarConfiguration _ => 1, + NewSphereConfiguration _ => 2, + CustomerUpdateParamsTaxConfigurationNumeral _ => 3, + CustomerUpdateParamsTaxConfigurationAnrok _ => 4, + CustomerUpdateParamsTaxConfigurationStripe _ => 5, + _ => -1, + }; + } } sealed class CustomerUpdateParamsTaxConfigurationConverter diff --git a/src/Orb/Models/Invoice.cs b/src/Orb/Models/Invoice.cs index 19746afef..e0b275ddc 100644 --- a/src/Orb/Models/Invoice.cs +++ b/src/Orb/Models/Invoice.cs @@ -2097,10 +2097,10 @@ public override void Validate() ); } - public virtual bool Equals(InvoiceLineItemAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceLineItemAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2109,6 +2109,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class InvoiceLineItemAdjustmentConverter : JsonConverter @@ -2518,10 +2531,10 @@ public override void Validate() ); } - public virtual bool Equals(InvoiceLineItemSubLineItem? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceLineItemSubLineItem? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2530,6 +2543,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } sealed class InvoiceLineItemSubLineItemConverter : JsonConverter diff --git a/src/Orb/Models/InvoiceLevelDiscount.cs b/src/Orb/Models/InvoiceLevelDiscount.cs index 33a9f2f42..2aab8015b 100644 --- a/src/Orb/Models/InvoiceLevelDiscount.cs +++ b/src/Orb/Models/InvoiceLevelDiscount.cs @@ -238,10 +238,10 @@ public override void Validate() ); } - public virtual bool Equals(InvoiceLevelDiscount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceLevelDiscount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -250,6 +250,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + PercentageDiscount _ => 0, + AmountDiscount _ => 1, + TrialDiscount _ => 2, + _ => -1, + }; + } } sealed class InvoiceLevelDiscountConverter : JsonConverter diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs index 1a2d621ee..f82b54167 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs @@ -714,10 +714,10 @@ public override void Validate() ); } - public virtual bool Equals(Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -726,6 +726,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class AdjustmentConverter : JsonConverter @@ -1127,10 +1140,10 @@ public override void Validate() ); } - public virtual bool Equals(SubLineItem? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubLineItem? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1139,6 +1152,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } sealed class SubLineItemConverter : JsonConverter diff --git a/src/Orb/Models/Invoices/InvoiceCreateParams.cs b/src/Orb/Models/Invoices/InvoiceCreateParams.cs index 072881080..2f356be1e 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -659,10 +659,10 @@ public override void Validate() } } - public virtual bool Equals(DueDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DueDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -671,6 +671,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class DueDateConverter : JsonConverter diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs index 65b1aa1d2..d9a84afa3 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs @@ -2059,10 +2059,10 @@ public override void Validate() ); } - public virtual bool Equals(Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2071,6 +2071,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class AdjustmentConverter : JsonConverter @@ -2472,10 +2485,10 @@ public override void Validate() ); } - public virtual bool Equals(SubLineItem? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubLineItem? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2484,6 +2497,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } sealed class SubLineItemConverter : JsonConverter diff --git a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs index 187f3f1d6..d9bab7336 100644 --- a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs @@ -394,10 +394,10 @@ public override void Validate() } } - public virtual bool Equals(InvoiceUpdateParamsDueDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceUpdateParamsDueDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -406,6 +406,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceUpdateParamsDueDateConverter : JsonConverter @@ -629,10 +639,10 @@ public override void Validate() } } - public virtual bool Equals(InvoiceDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -641,6 +651,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceDateConverter : JsonConverter diff --git a/src/Orb/Models/NewFloatingBulkPrice.cs b/src/Orb/Models/NewFloatingBulkPrice.cs index f1556201c..3fb0f55ea 100644 --- a/src/Orb/Models/NewFloatingBulkPrice.cs +++ b/src/Orb/Models/NewFloatingBulkPrice.cs @@ -595,10 +595,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -607,6 +607,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ConversionRateConfigConverter : JsonConverter diff --git a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs index 39538ca7e..2fb16a788 100644 --- a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs @@ -780,10 +780,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingBulkWithProrationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingBulkWithProrationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -792,6 +792,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingBulkWithProrationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs index a2833ffd9..09f914877 100644 --- a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs @@ -797,10 +797,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingCumulativeGroupedBulkPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingCumulativeGroupedBulkPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -809,6 +809,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingCumulativeGroupedBulkPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs index bba677c43..9e4c7d68b 100644 --- a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs @@ -710,10 +710,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingGroupedAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingGroupedAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -722,6 +722,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingGroupedAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs index 5790f1150..6538621c6 100644 --- a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs @@ -805,10 +805,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingGroupedTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingGroupedTieredPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -817,6 +817,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingGroupedTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs index 31238c9f6..581f2dfe8 100644 --- a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs @@ -773,10 +773,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingGroupedTieredPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingGroupedTieredPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -785,6 +785,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingGroupedTieredPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs index 364c281cf..18322d410 100644 --- a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs @@ -923,10 +923,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingGroupedWithMeteredMinimumPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewFloatingGroupedWithMeteredMinimumPriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -935,6 +937,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingGroupedWithMeteredMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs index 81c51bea7..17138f55c 100644 --- a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs @@ -723,10 +723,10 @@ public override void Validate() public virtual bool Equals( NewFloatingGroupedWithProratedMinimumPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -735,6 +735,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingGroupedWithProratedMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingMatrixPrice.cs b/src/Orb/Models/NewFloatingMatrixPrice.cs index a92a46f91..ad89afcc8 100644 --- a/src/Orb/Models/NewFloatingMatrixPrice.cs +++ b/src/Orb/Models/NewFloatingMatrixPrice.cs @@ -608,10 +608,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingMatrixPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingMatrixPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -620,6 +620,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingMatrixPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs index 5bb1a68d0..fec00e68c 100644 --- a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs @@ -621,10 +621,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingMatrixWithAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingMatrixWithAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -633,6 +633,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingMatrixWithAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs index cc6ccb604..81c0c40f6 100644 --- a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs @@ -811,10 +811,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingMatrixWithDisplayNamePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingMatrixWithDisplayNamePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -823,6 +823,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingMatrixWithDisplayNamePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs index cd56d95a7..c081363d2 100644 --- a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs @@ -804,10 +804,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingMaxGroupTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingMaxGroupTieredPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -816,6 +816,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingMaxGroupTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs index d6881251e..6bb7346c7 100644 --- a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs +++ b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs @@ -710,10 +710,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingMinimumCompositePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingMinimumCompositePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -722,6 +722,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingMinimumCompositePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingPackagePrice.cs b/src/Orb/Models/NewFloatingPackagePrice.cs index 90e5739f0..00cab9673 100644 --- a/src/Orb/Models/NewFloatingPackagePrice.cs +++ b/src/Orb/Models/NewFloatingPackagePrice.cs @@ -608,10 +608,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -620,6 +620,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs index 7ec08d46e..9339113d6 100644 --- a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs @@ -705,10 +705,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingPackageWithAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingPackageWithAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -717,6 +717,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingPackageWithAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs index 14cc6f4ab..cf85e7470 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs @@ -925,10 +925,10 @@ public override void Validate() public virtual bool Equals( NewFloatingScalableMatrixWithTieredPricingPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -937,6 +937,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingScalableMatrixWithTieredPricingPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs index b255c0f40..b1343071b 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs @@ -859,10 +859,10 @@ public override void Validate() public virtual bool Equals( NewFloatingScalableMatrixWithUnitPricingPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -871,6 +871,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingScalableMatrixWithUnitPricingPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs index 349b4043e..e94980fad 100644 --- a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs @@ -793,10 +793,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingThresholdTotalAmountPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingThresholdTotalAmountPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -805,6 +805,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingThresholdTotalAmountPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingTieredPackagePrice.cs b/src/Orb/Models/NewFloatingTieredPackagePrice.cs index d01eec41f..9c6656ef8 100644 --- a/src/Orb/Models/NewFloatingTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingTieredPackagePrice.cs @@ -773,10 +773,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingTieredPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -785,6 +785,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs index da3834a7d..f75c6b836 100644 --- a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs @@ -806,10 +806,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingTieredPackageWithMinimumPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewFloatingTieredPackageWithMinimumPriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -818,6 +820,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingTieredPackageWithMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingTieredPrice.cs b/src/Orb/Models/NewFloatingTieredPrice.cs index 0f6926bb7..ce6141aa9 100644 --- a/src/Orb/Models/NewFloatingTieredPrice.cs +++ b/src/Orb/Models/NewFloatingTieredPrice.cs @@ -608,10 +608,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingTieredPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingTieredPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -620,6 +620,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingTieredPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs index 1316ef516..8ddd4ab0f 100644 --- a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs @@ -833,10 +833,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingTieredWithMinimumPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingTieredWithMinimumPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -845,6 +845,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingTieredWithMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs index 2d7415f40..3c0a5c86b 100644 --- a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs @@ -786,10 +786,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingTieredWithProrationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingTieredWithProrationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -798,6 +798,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingTieredWithProrationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingUnitPrice.cs b/src/Orb/Models/NewFloatingUnitPrice.cs index f9f356f27..8e3d309e2 100644 --- a/src/Orb/Models/NewFloatingUnitPrice.cs +++ b/src/Orb/Models/NewFloatingUnitPrice.cs @@ -607,10 +607,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingUnitPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingUnitPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -619,6 +619,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingUnitPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs index 19fe09d50..6df010868 100644 --- a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs +++ b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs @@ -693,10 +693,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingUnitWithPercentPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingUnitWithPercentPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -705,6 +705,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingUnitWithPercentPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs index 712e77413..cbdcd33d1 100644 --- a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs @@ -689,10 +689,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewFloatingUnitWithProrationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewFloatingUnitWithProrationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -701,6 +701,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingUnitWithProrationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanBulkPrice.cs b/src/Orb/Models/NewPlanBulkPrice.cs index d9ea64713..83801bf31 100644 --- a/src/Orb/Models/NewPlanBulkPrice.cs +++ b/src/Orb/Models/NewPlanBulkPrice.cs @@ -622,10 +622,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanBulkPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanBulkPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -634,6 +634,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanBulkPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs index a4b4bb670..dda98ba1c 100644 --- a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs +++ b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs @@ -822,10 +822,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanBulkWithProrationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanBulkWithProrationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -834,6 +834,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanBulkWithProrationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs index 4c29be8be..2f0814789 100644 --- a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs @@ -840,10 +840,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanCumulativeGroupedBulkPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanCumulativeGroupedBulkPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -852,6 +852,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanCumulativeGroupedBulkPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs index 3e8af7268..0b487609f 100644 --- a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs +++ b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs @@ -734,10 +734,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanGroupedAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanGroupedAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -746,6 +746,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanGroupedAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs index 32cc6fa5f..75c4dccda 100644 --- a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs @@ -835,10 +835,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanGroupedTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanGroupedTieredPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -847,6 +847,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanGroupedTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanGroupedTieredPrice.cs b/src/Orb/Models/NewPlanGroupedTieredPrice.cs index 04e9f9e2f..5a4d96d89 100644 --- a/src/Orb/Models/NewPlanGroupedTieredPrice.cs +++ b/src/Orb/Models/NewPlanGroupedTieredPrice.cs @@ -812,10 +812,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanGroupedTieredPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanGroupedTieredPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -824,6 +824,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanGroupedTieredPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs index ef54d0616..7320e9039 100644 --- a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs @@ -987,10 +987,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanGroupedWithMeteredMinimumPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanGroupedWithMeteredMinimumPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -999,6 +999,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanGroupedWithMeteredMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs index 9d7e4ae9a..9306527c0 100644 --- a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs @@ -744,10 +744,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanGroupedWithProratedMinimumPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanGroupedWithProratedMinimumPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -756,6 +756,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanGroupedWithProratedMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanMatrixPrice.cs b/src/Orb/Models/NewPlanMatrixPrice.cs index e4a796c06..f962b83b7 100644 --- a/src/Orb/Models/NewPlanMatrixPrice.cs +++ b/src/Orb/Models/NewPlanMatrixPrice.cs @@ -622,10 +622,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanMatrixPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanMatrixPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -634,6 +634,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanMatrixPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs index 01ef02e75..d3eea5a9a 100644 --- a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs @@ -636,10 +636,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanMatrixWithAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanMatrixWithAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -648,6 +648,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanMatrixWithAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs index 6d776c94b..794b66f64 100644 --- a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs @@ -843,10 +843,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanMatrixWithDisplayNamePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanMatrixWithDisplayNamePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -855,6 +855,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanMatrixWithDisplayNamePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs index 277f700bd..b3e70bd5a 100644 --- a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs @@ -834,10 +834,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanMaxGroupTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanMaxGroupTieredPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -846,6 +846,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanMaxGroupTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanMinimumCompositePrice.cs b/src/Orb/Models/NewPlanMinimumCompositePrice.cs index 7ac355c92..b20cf96a8 100644 --- a/src/Orb/Models/NewPlanMinimumCompositePrice.cs +++ b/src/Orb/Models/NewPlanMinimumCompositePrice.cs @@ -733,10 +733,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanMinimumCompositePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanMinimumCompositePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -745,6 +745,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanMinimumCompositePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanPackagePrice.cs b/src/Orb/Models/NewPlanPackagePrice.cs index f19b737dc..1b9ce322c 100644 --- a/src/Orb/Models/NewPlanPackagePrice.cs +++ b/src/Orb/Models/NewPlanPackagePrice.cs @@ -622,10 +622,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -634,6 +634,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs index 8edefd077..8337aa005 100644 --- a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs +++ b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs @@ -730,10 +730,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanPackageWithAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanPackageWithAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -742,6 +742,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanPackageWithAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs index 85a5083ba..d9f46e354 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs @@ -970,10 +970,10 @@ public override void Validate() public virtual bool Equals( NewPlanScalableMatrixWithTieredPricingPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -982,6 +982,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanScalableMatrixWithTieredPricingPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs index 18f3f4163..fd83a553f 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs @@ -886,10 +886,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanScalableMatrixWithUnitPricingPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewPlanScalableMatrixWithUnitPricingPriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -898,6 +900,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanScalableMatrixWithUnitPricingPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs index a915628a1..9a9a8c5da 100644 --- a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs @@ -836,10 +836,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanThresholdTotalAmountPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanThresholdTotalAmountPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -848,6 +848,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanThresholdTotalAmountPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanTieredPackagePrice.cs b/src/Orb/Models/NewPlanTieredPackagePrice.cs index 05c53e2a4..3aa306b95 100644 --- a/src/Orb/Models/NewPlanTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanTieredPackagePrice.cs @@ -812,10 +812,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanTieredPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -824,6 +824,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs index 847caaeca..2009b73a8 100644 --- a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs @@ -837,10 +837,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanTieredPackageWithMinimumPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanTieredPackageWithMinimumPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -849,6 +849,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanTieredPackageWithMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanTieredPrice.cs b/src/Orb/Models/NewPlanTieredPrice.cs index 377e0a01f..b1ec2f26b 100644 --- a/src/Orb/Models/NewPlanTieredPrice.cs +++ b/src/Orb/Models/NewPlanTieredPrice.cs @@ -622,10 +622,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanTieredPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanTieredPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -634,6 +634,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanTieredPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs index 499064eb6..cda64d35f 100644 --- a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs +++ b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs @@ -868,10 +868,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanTieredWithMinimumPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanTieredWithMinimumPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -880,6 +880,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanTieredWithMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanUnitPrice.cs b/src/Orb/Models/NewPlanUnitPrice.cs index bdba6ab25..f0a3b5c23 100644 --- a/src/Orb/Models/NewPlanUnitPrice.cs +++ b/src/Orb/Models/NewPlanUnitPrice.cs @@ -622,10 +622,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanUnitPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanUnitPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -634,6 +634,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanUnitPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs index 7640eaaa5..02da87f8a 100644 --- a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs +++ b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs @@ -716,10 +716,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanUnitWithPercentPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanUnitWithPercentPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -728,6 +728,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanUnitWithPercentPriceConversionRateConfigConverter diff --git a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs index 156e087aa..cc6b0df67 100644 --- a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs +++ b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs @@ -713,10 +713,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewPlanUnitWithProrationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewPlanUnitWithProrationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -725,6 +725,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanUnitWithProrationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs index 4c49cef0a..5b869ca27 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs @@ -347,10 +347,10 @@ public override void Validate() ); } - public virtual bool Equals(MigrationCancelResponseEffectiveTime? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MigrationCancelResponseEffectiveTime? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -359,6 +359,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + ApiEnum _ => 2, + _ => -1, + }; + } } sealed class MigrationCancelResponseEffectiveTimeConverter diff --git a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs index 9f189a3cd..6dfb47e31 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs @@ -346,10 +346,10 @@ public override void Validate() ); } - public virtual bool Equals(MigrationListResponseEffectiveTime? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MigrationListResponseEffectiveTime? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -358,6 +358,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + ApiEnum _ => 2, + _ => -1, + }; + } } sealed class MigrationListResponseEffectiveTimeConverter diff --git a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs index 46ea0ab86..bfaf12781 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs @@ -317,10 +317,10 @@ public override void Validate() this.Switch((_) => { }, (_) => { }, (unionMember2) => unionMember2.Validate()); } - public virtual bool Equals(EffectiveTime? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EffectiveTime? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -329,6 +329,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + ApiEnum _ => 2, + _ => -1, + }; + } } sealed class EffectiveTimeConverter : JsonConverter diff --git a/src/Orb/Models/Plans/Plan.cs b/src/Orb/Models/Plans/Plan.cs index 22fd4a2fb..cb3b98f2f 100644 --- a/src/Orb/Models/Plans/Plan.cs +++ b/src/Orb/Models/Plans/Plan.cs @@ -813,10 +813,10 @@ public override void Validate() ); } - public virtual bool Equals(PlanAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PlanAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -825,6 +825,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + Models::PlanPhaseUsageDiscountAdjustment _ => 0, + Models::PlanPhaseAmountDiscountAdjustment _ => 1, + Models::PlanPhasePercentageDiscountAdjustment _ => 2, + Models::PlanPhaseMinimumAdjustment _ => 3, + Models::PlanPhaseMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class PlanAdjustmentConverter : JsonConverter diff --git a/src/Orb/Models/Plans/PlanCreateParams.cs b/src/Orb/Models/Plans/PlanCreateParams.cs index 74addba60..84a1e3e07 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -2254,10 +2254,10 @@ public override void Validate() ); } - public virtual bool Equals(PricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2266,6 +2266,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + TieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + NewPlanMinimumCompositePrice _ => 28, + Percent _ => 29, + EventOutput _ => 30, + _ => -1, + }; + } } sealed class PricePriceConverter : JsonConverter @@ -3803,10 +3842,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3815,6 +3854,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ConversionRateConfigConverter : JsonConverter @@ -4646,10 +4695,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4658,6 +4707,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithProrationConversionRateConfigConverter @@ -5441,10 +5500,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5453,6 +5512,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -6236,10 +6305,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6248,6 +6317,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class CumulativeGroupedAllocationConversionRateConfigConverter @@ -6971,10 +7050,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6983,6 +7062,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PercentConversionRateConfigConverter : JsonConverter @@ -7743,10 +7832,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7755,6 +7844,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class EventOutputConversionRateConfigConverter @@ -8244,10 +8343,10 @@ public override void Validate() ); } - public virtual bool Equals(AdjustmentAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(AdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8256,6 +8355,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class AdjustmentAdjustmentConverter : JsonConverter diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index 0d3290a21..1d91e84f2 100644 --- a/src/Orb/Models/Price.cs +++ b/src/Orb/Models/Price.cs @@ -2152,10 +2152,10 @@ public override void Validate() ); } - public virtual bool Equals(Price? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2164,6 +2164,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + Unit _ => 0, + Tiered _ => 1, + Bulk _ => 2, + BulkWithFilters _ => 3, + Package _ => 4, + Matrix _ => 5, + ThresholdTotalAmount _ => 6, + TieredPackage _ => 7, + TieredWithMinimum _ => 8, + GroupedTiered _ => 9, + TieredPackageWithMinimum _ => 10, + PackageWithAllocation _ => 11, + UnitWithPercent _ => 12, + MatrixWithAllocation _ => 13, + TieredWithProration _ => 14, + UnitWithProration _ => 15, + GroupedAllocation _ => 16, + BulkWithProration _ => 17, + GroupedWithProratedMinimum _ => 18, + GroupedWithMeteredMinimum _ => 19, + GroupedWithMinMaxThresholds _ => 20, + MatrixWithDisplayName _ => 21, + GroupedTieredPackage _ => 22, + MaxGroupTieredPackage _ => 23, + ScalableMatrixWithUnitPricing _ => 24, + ScalableMatrixWithTieredPricing _ => 25, + CumulativeGroupedBulk _ => 26, + CumulativeGroupedAllocation _ => 27, + MinimumComposite _ => 28, + Percent _ => 29, + EventOutput _ => 30, + _ => -1, + }; + } } sealed class PriceConverter : JsonConverter @@ -3764,10 +3803,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(UnitConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnitConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3776,6 +3815,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class UnitConversionRateConfigConverter : JsonConverter @@ -4822,10 +4871,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4834,6 +4883,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredConversionRateConfigConverter : JsonConverter @@ -5877,10 +5936,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(BulkConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(BulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5889,6 +5948,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class BulkConversionRateConfigConverter : JsonConverter @@ -7213,10 +7282,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(BulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(BulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7225,6 +7294,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class BulkWithFiltersConversionRateConfigConverter @@ -8272,10 +8351,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PackageConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8284,6 +8363,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PackageConversionRateConfigConverter : JsonConverter @@ -9330,10 +9419,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MatrixConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MatrixConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9342,6 +9431,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MatrixConversionRateConfigConverter : JsonConverter @@ -10411,10 +10510,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ThresholdTotalAmountConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ThresholdTotalAmountConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10423,6 +10522,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ThresholdTotalAmountConversionRateConfigConverter @@ -11678,10 +11787,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredPackageConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -11690,6 +11799,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredPackageConversionRateConfigConverter @@ -12933,10 +13052,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -12945,6 +13064,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithMinimumConversionRateConfigConverter @@ -14239,10 +14368,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedTieredConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedTieredConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -14251,6 +14380,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedTieredConversionRateConfigConverter @@ -15502,10 +15641,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredPackageWithMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredPackageWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -15514,6 +15653,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredPackageWithMinimumConversionRateConfigConverter @@ -16776,10 +16925,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PackageWithAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PackageWithAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16788,6 +16937,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PackageWithAllocationConversionRateConfigConverter @@ -17943,10 +18102,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(UnitWithPercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnitWithPercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17955,6 +18114,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class UnitWithPercentConversionRateConfigConverter @@ -19110,10 +19279,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MatrixWithAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MatrixWithAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -19122,6 +19291,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MatrixWithAllocationConversionRateConfigConverter @@ -20188,10 +20367,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -20200,6 +20379,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithProrationConversionRateConfigConverter @@ -21447,10 +21636,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(UnitWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnitWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -21459,6 +21648,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class UnitWithProrationConversionRateConfigConverter @@ -22605,10 +22804,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -22617,6 +22816,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedAllocationConversionRateConfigConverter @@ -23971,10 +24180,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(BulkWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(BulkWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -23983,6 +24192,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class BulkWithProrationConversionRateConfigConverter @@ -25057,10 +25276,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithProratedMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithProratedMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -25069,6 +25288,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithProratedMinimumConversionRateConfigConverter @@ -26247,10 +26476,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMeteredMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMeteredMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -26259,6 +26488,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMeteredMinimumConversionRateConfigConverter @@ -27681,10 +27920,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -27693,6 +27932,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -28876,10 +29125,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -28888,6 +29137,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MatrixWithDisplayNameConversionRateConfigConverter @@ -30158,10 +30417,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -30170,6 +30429,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedTieredPackageConversionRateConfigConverter @@ -31436,10 +31705,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -31448,6 +31717,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MaxGroupTieredPackageConversionRateConfigConverter @@ -32723,10 +33002,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -32735,6 +33014,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter @@ -34062,10 +34351,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -34074,6 +34363,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter @@ -35471,10 +35770,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -35483,6 +35782,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class CumulativeGroupedBulkConversionRateConfigConverter @@ -36758,10 +37067,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -36770,6 +37079,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class CumulativeGroupedAllocationConversionRateConfigConverter @@ -37949,10 +38268,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MinimumCompositeConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MinimumCompositeConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -37961,6 +38280,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MinimumCompositeConversionRateConfigConverter @@ -39108,10 +39437,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -39120,6 +39449,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PercentConversionRateConfigConverter : JsonConverter @@ -40245,10 +40584,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -40257,6 +40596,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class EventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Prices/EvaluatePriceGroup.cs b/src/Orb/Models/Prices/EvaluatePriceGroup.cs index 273f65273..beddf3325 100644 --- a/src/Orb/Models/Prices/EvaluatePriceGroup.cs +++ b/src/Orb/Models/Prices/EvaluatePriceGroup.cs @@ -318,10 +318,10 @@ public override void Validate() } } - public virtual bool Equals(GroupingValue? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupingValue? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -330,6 +330,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class GroupingValueConverter : JsonConverter diff --git a/src/Orb/Models/Prices/PriceCreateParams.cs b/src/Orb/Models/Prices/PriceCreateParams.cs index 669c82bb7..69bcaa228 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -2027,10 +2027,10 @@ public override void Validate() ); } - public virtual bool Equals(Body? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Body? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2039,6 +2039,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewFloatingUnitPrice _ => 0, + NewFloatingTieredPrice _ => 1, + NewFloatingBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewFloatingPackagePrice _ => 4, + NewFloatingMatrixPrice _ => 5, + NewFloatingThresholdTotalAmountPrice _ => 6, + NewFloatingTieredPackagePrice _ => 7, + NewFloatingTieredWithMinimumPrice _ => 8, + NewFloatingGroupedTieredPrice _ => 9, + NewFloatingTieredPackageWithMinimumPrice _ => 10, + NewFloatingPackageWithAllocationPrice _ => 11, + NewFloatingUnitWithPercentPrice _ => 12, + NewFloatingMatrixWithAllocationPrice _ => 13, + NewFloatingTieredWithProrationPrice _ => 14, + NewFloatingUnitWithProrationPrice _ => 15, + NewFloatingGroupedAllocationPrice _ => 16, + NewFloatingBulkWithProrationPrice _ => 17, + NewFloatingGroupedWithProratedMinimumPrice _ => 18, + NewFloatingGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewFloatingMatrixWithDisplayNamePrice _ => 21, + NewFloatingGroupedTieredPackagePrice _ => 22, + NewFloatingMaxGroupTieredPackagePrice _ => 23, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 24, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 25, + NewFloatingCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + NewFloatingMinimumCompositePrice _ => 28, + Percent _ => 29, + EventOutput _ => 30, + _ => -1, + }; + } } sealed class BodyConverter : JsonConverter @@ -3564,10 +3603,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3576,6 +3615,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ConversionRateConfigConverter : JsonConverter @@ -4342,10 +4391,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4354,6 +4403,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -5121,10 +5180,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5133,6 +5192,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class CumulativeGroupedAllocationConversionRateConfigConverter @@ -5840,10 +5909,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5852,6 +5921,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PercentConversionRateConfigConverter : JsonConverter @@ -6596,10 +6675,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6608,6 +6687,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class EventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs index 5fde15e97..694aab906 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -2201,10 +2201,10 @@ public override void Validate() ); } - public virtual bool Equals(Price? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2213,6 +2213,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewFloatingUnitPrice _ => 0, + NewFloatingTieredPrice _ => 1, + NewFloatingBulkPrice _ => 2, + PriceBulkWithFilters _ => 3, + NewFloatingPackagePrice _ => 4, + NewFloatingMatrixPrice _ => 5, + NewFloatingThresholdTotalAmountPrice _ => 6, + NewFloatingTieredPackagePrice _ => 7, + NewFloatingTieredWithMinimumPrice _ => 8, + NewFloatingGroupedTieredPrice _ => 9, + NewFloatingTieredPackageWithMinimumPrice _ => 10, + NewFloatingPackageWithAllocationPrice _ => 11, + NewFloatingUnitWithPercentPrice _ => 12, + NewFloatingMatrixWithAllocationPrice _ => 13, + NewFloatingTieredWithProrationPrice _ => 14, + NewFloatingUnitWithProrationPrice _ => 15, + NewFloatingGroupedAllocationPrice _ => 16, + NewFloatingBulkWithProrationPrice _ => 17, + NewFloatingGroupedWithProratedMinimumPrice _ => 18, + NewFloatingGroupedWithMeteredMinimumPrice _ => 19, + PriceGroupedWithMinMaxThresholds _ => 20, + NewFloatingMatrixWithDisplayNamePrice _ => 21, + NewFloatingGroupedTieredPackagePrice _ => 22, + NewFloatingMaxGroupTieredPackagePrice _ => 23, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 24, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 25, + NewFloatingCumulativeGroupedBulkPrice _ => 26, + PriceCumulativeGroupedAllocation _ => 27, + NewFloatingMinimumCompositePrice _ => 28, + PricePercent _ => 29, + PriceEventOutput _ => 30, + _ => -1, + }; + } } sealed class PriceConverter : JsonConverter @@ -3802,10 +3841,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3814,6 +3853,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceBulkWithFiltersConversionRateConfigConverter @@ -4593,10 +4642,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceGroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceGroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4605,6 +4654,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -5384,10 +5443,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceCumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5396,6 +5455,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -6108,10 +6177,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PricePercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PricePercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6120,6 +6189,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PricePercentConversionRateConfigConverter @@ -6879,10 +6958,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceEventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceEventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6891,6 +6970,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs index 83626d51d..025872a13 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs @@ -2537,10 +2537,10 @@ public override void Validate() ); } - public virtual bool Equals(PriceEvaluatePreviewEventsParamsPriceEvaluationPrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceEvaluatePreviewEventsParamsPriceEvaluationPrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2549,6 +2549,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewFloatingUnitPrice _ => 0, + NewFloatingTieredPrice _ => 1, + NewFloatingBulkPrice _ => 2, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters _ => 3, + NewFloatingPackagePrice _ => 4, + NewFloatingMatrixPrice _ => 5, + NewFloatingThresholdTotalAmountPrice _ => 6, + NewFloatingTieredPackagePrice _ => 7, + NewFloatingTieredWithMinimumPrice _ => 8, + NewFloatingGroupedTieredPrice _ => 9, + NewFloatingTieredPackageWithMinimumPrice _ => 10, + NewFloatingPackageWithAllocationPrice _ => 11, + NewFloatingUnitWithPercentPrice _ => 12, + NewFloatingMatrixWithAllocationPrice _ => 13, + NewFloatingTieredWithProrationPrice _ => 14, + NewFloatingUnitWithProrationPrice _ => 15, + NewFloatingGroupedAllocationPrice _ => 16, + NewFloatingBulkWithProrationPrice _ => 17, + NewFloatingGroupedWithProratedMinimumPrice _ => 18, + NewFloatingGroupedWithMeteredMinimumPrice _ => 19, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds _ => 20, + NewFloatingMatrixWithDisplayNamePrice _ => 21, + NewFloatingGroupedTieredPackagePrice _ => 22, + NewFloatingMaxGroupTieredPackagePrice _ => 23, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 24, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 25, + NewFloatingCumulativeGroupedBulkPrice _ => 26, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation _ => 27, + NewFloatingMinimumCompositePrice _ => 28, + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent _ => 29, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput _ => 30, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceConverter @@ -4222,10 +4261,10 @@ public override void Validate() public virtual bool Equals( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4234,6 +4273,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersConversionRateConfigConverter @@ -5059,10 +5108,10 @@ public override void Validate() public virtual bool Equals( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5071,6 +5120,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -5896,10 +5955,10 @@ public override void Validate() public virtual bool Equals( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5908,6 +5967,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -6675,10 +6744,10 @@ public override void Validate() public virtual bool Equals( PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6687,6 +6756,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentConversionRateConfigConverter @@ -7501,10 +7580,10 @@ public override void Validate() public virtual bool Equals( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7513,6 +7592,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/SharedDiscount.cs b/src/Orb/Models/SharedDiscount.cs index 908f8da14..5da3ce72d 100644 --- a/src/Orb/Models/SharedDiscount.cs +++ b/src/Orb/Models/SharedDiscount.cs @@ -275,10 +275,10 @@ public override void Validate() ); } - public virtual bool Equals(SharedDiscount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SharedDiscount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -287,6 +287,18 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + PercentageDiscount _ => 0, + TrialDiscount _ => 1, + UsageDiscount _ => 2, + AmountDiscount _ => 3, + _ => -1, + }; + } } sealed class SharedDiscountConverter : JsonConverter diff --git a/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs b/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs index f422b5d00..51715ba27 100644 --- a/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs +++ b/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs @@ -802,10 +802,10 @@ public override void Validate() ); } - public virtual bool Equals(DiscountInterval? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DiscountInterval? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -814,6 +814,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + AmountDiscountInterval _ => 0, + PercentageDiscountInterval _ => 1, + UsageDiscountInterval _ => 2, + _ => -1, + }; + } } sealed class DiscountIntervalConverter : JsonConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs index c3738bafd..85a976e12 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs @@ -624,10 +624,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionBulkPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionBulkPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -636,6 +636,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionBulkPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs index cbdc0dedb..3577de603 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs @@ -805,10 +805,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionBulkWithProrationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionBulkWithProrationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -817,6 +817,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionBulkWithProrationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs index 56727589b..62ce894a9 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs @@ -815,10 +815,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionCumulativeGroupedBulkPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewSubscriptionCumulativeGroupedBulkPriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -827,6 +829,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionCumulativeGroupedBulkPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs index 49b7a74e5..dcdcfbb56 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs @@ -728,10 +728,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionGroupedAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionGroupedAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -740,6 +740,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionGroupedAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs index 68c4f050a..b1c090704 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs @@ -823,10 +823,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionGroupedTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewSubscriptionGroupedTieredPackagePriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -835,6 +837,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionGroupedTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs index 41a964457..cfa894bcd 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs @@ -792,10 +792,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionGroupedTieredPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionGroupedTieredPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -804,6 +804,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionGroupedTieredPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs index c38a33811..452dec270 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs @@ -944,10 +944,10 @@ public override void Validate() public virtual bool Equals( NewSubscriptionGroupedWithMeteredMinimumPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -956,6 +956,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionGroupedWithMeteredMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs index 1b446af59..44044b9ea 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs @@ -742,10 +742,10 @@ public override void Validate() public virtual bool Equals( NewSubscriptionGroupedWithProratedMinimumPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -754,6 +754,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionGroupedWithProratedMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs index 6f683c8b9..5248614bd 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs @@ -627,10 +627,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionMatrixPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionMatrixPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -639,6 +639,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionMatrixPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs index 46027842b..eabc8a54d 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs @@ -639,10 +639,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionMatrixWithAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewSubscriptionMatrixWithAllocationPriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -651,6 +653,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionMatrixWithAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs index 89eba9f1c..83a13ceb1 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs @@ -829,10 +829,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionMatrixWithDisplayNamePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewSubscriptionMatrixWithDisplayNamePriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -841,6 +843,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionMatrixWithDisplayNamePriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs index 1966893ed..dcfb0b500 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs @@ -822,10 +822,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionMaxGroupTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewSubscriptionMaxGroupTieredPackagePriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -834,6 +836,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionMaxGroupTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs index 706e9d283..4f8e93ebb 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs @@ -728,10 +728,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionMinimumCompositePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionMinimumCompositePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -740,6 +740,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionMinimumCompositePriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs index 87c01662d..a2a712adb 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs @@ -627,10 +627,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -639,6 +639,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs index 509f0d605..02cc7b2b2 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs @@ -723,10 +723,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionPackageWithAllocationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewSubscriptionPackageWithAllocationPriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -735,6 +737,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionPackageWithAllocationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs index b520b6d52..5474b20b3 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs @@ -950,10 +950,10 @@ public override void Validate() public virtual bool Equals( NewSubscriptionScalableMatrixWithTieredPricingPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -962,6 +962,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionScalableMatrixWithTieredPricingPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs index dc0fcf029..4f02edef0 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs @@ -884,10 +884,10 @@ public override void Validate() public virtual bool Equals( NewSubscriptionScalableMatrixWithUnitPricingPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -896,6 +896,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionScalableMatrixWithUnitPricingPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs index 7733eb122..722539fec 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs @@ -811,10 +811,12 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionThresholdTotalAmountPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + NewSubscriptionThresholdTotalAmountPriceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -823,6 +825,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionThresholdTotalAmountPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs index 7a481a530..5ea2b4d74 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs @@ -792,10 +792,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionTieredPackagePriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionTieredPackagePriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -804,6 +804,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionTieredPackagePriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs index 8d2b5353f..7c171af70 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs @@ -824,10 +824,10 @@ public override void Validate() public virtual bool Equals( NewSubscriptionTieredPackageWithMinimumPriceConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -836,6 +836,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionTieredPackageWithMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs index 7c8041198..8c6517413 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs @@ -627,10 +627,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionTieredPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionTieredPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -639,6 +639,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionTieredPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs index a6ae2f2af..80ebf4dd6 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs @@ -851,10 +851,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionTieredWithMinimumPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionTieredWithMinimumPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -863,6 +863,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionTieredWithMinimumPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs index fa959a1b1..beb0130a1 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs @@ -627,10 +627,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionUnitPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionUnitPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -639,6 +639,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionUnitPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs index fb61fa4e1..66ec5b681 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs @@ -709,10 +709,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionUnitWithPercentPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionUnitWithPercentPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -721,6 +721,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionUnitWithPercentPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs index 82a5b999c..3bc175cd6 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs @@ -707,10 +707,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(NewSubscriptionUnitWithProrationPriceConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(NewSubscriptionUnitWithProrationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -719,6 +719,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewSubscriptionUnitWithProrationPriceConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/Subscription.cs b/src/Orb/Models/Subscriptions/Subscription.cs index e3ce0f664..6fcd61393 100644 --- a/src/Orb/Models/Subscriptions/Subscription.cs +++ b/src/Orb/Models/Subscriptions/Subscription.cs @@ -801,10 +801,10 @@ public override void Validate() ); } - public virtual bool Equals(DiscountInterval? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DiscountInterval? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -813,6 +813,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + AmountDiscountInterval _ => 0, + PercentageDiscountInterval _ => 1, + UsageDiscountInterval _ => 2, + _ => -1, + }; + } } sealed class DiscountIntervalConverter : JsonConverter diff --git a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs index bbd1cc96f..a337294da 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -1269,10 +1269,10 @@ public override void Validate() ); } - public virtual bool Equals(Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1281,6 +1281,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class AdjustmentConverter : JsonConverter @@ -3567,10 +3580,10 @@ public override void Validate() ); } - public virtual bool Equals(Price? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3579,6 +3592,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewSubscriptionUnitPrice _ => 0, + NewSubscriptionTieredPrice _ => 1, + NewSubscriptionBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewSubscriptionPackagePrice _ => 4, + NewSubscriptionMatrixPrice _ => 5, + NewSubscriptionThresholdTotalAmountPrice _ => 6, + NewSubscriptionTieredPackagePrice _ => 7, + NewSubscriptionTieredWithMinimumPrice _ => 8, + NewSubscriptionGroupedTieredPrice _ => 9, + NewSubscriptionTieredPackageWithMinimumPrice _ => 10, + NewSubscriptionPackageWithAllocationPrice _ => 11, + NewSubscriptionUnitWithPercentPrice _ => 12, + NewSubscriptionMatrixWithAllocationPrice _ => 13, + TieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + NewSubscriptionMinimumCompositePrice _ => 28, + Percent _ => 29, + EventOutput _ => 30, + _ => -1, + }; + } } sealed class PriceConverter : JsonConverter @@ -5123,10 +5175,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5135,6 +5187,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ConversionRateConfigConverter : JsonConverter @@ -5966,10 +6028,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5978,6 +6040,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithProrationConversionRateConfigConverter @@ -6761,10 +6833,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6773,6 +6845,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -7556,10 +7638,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7568,6 +7650,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class CumulativeGroupedAllocationConversionRateConfigConverter @@ -8291,10 +8383,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8303,6 +8395,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PercentConversionRateConfigConverter : JsonConverter @@ -9063,10 +9165,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9075,6 +9177,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class EventOutputConversionRateConfigConverter @@ -9747,10 +9859,10 @@ public override void Validate() ); } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9759,6 +9871,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter @@ -12131,10 +12256,10 @@ public override void Validate() ); } - public virtual bool Equals(ReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -12143,6 +12268,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewSubscriptionUnitPrice _ => 0, + NewSubscriptionTieredPrice _ => 1, + NewSubscriptionBulkPrice _ => 2, + ReplacePricePriceBulkWithFilters _ => 3, + NewSubscriptionPackagePrice _ => 4, + NewSubscriptionMatrixPrice _ => 5, + NewSubscriptionThresholdTotalAmountPrice _ => 6, + NewSubscriptionTieredPackagePrice _ => 7, + NewSubscriptionTieredWithMinimumPrice _ => 8, + NewSubscriptionGroupedTieredPrice _ => 9, + NewSubscriptionTieredPackageWithMinimumPrice _ => 10, + NewSubscriptionPackageWithAllocationPrice _ => 11, + NewSubscriptionUnitWithPercentPrice _ => 12, + NewSubscriptionMatrixWithAllocationPrice _ => 13, + ReplacePricePriceTieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + ReplacePricePriceCumulativeGroupedAllocation _ => 27, + NewSubscriptionMinimumCompositePrice _ => 28, + ReplacePricePricePercent _ => 29, + ReplacePricePriceEventOutput _ => 30, + _ => -1, + }; + } } sealed class ReplacePricePriceConverter : JsonConverter @@ -13773,10 +13937,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -13785,6 +13949,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter @@ -14648,10 +14822,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -14660,6 +14834,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter @@ -15462,10 +15646,10 @@ public override void Validate() public virtual bool Equals( ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -15474,6 +15658,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -16278,10 +16472,10 @@ public override void Validate() public virtual bool Equals( ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16290,6 +16484,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -17036,10 +17240,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePricePercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePricePercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17048,6 +17252,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePricePercentConversionRateConfigConverter @@ -17830,10 +18044,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceEventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceEventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17842,6 +18056,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceEventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index 1dd3bbe49..ee856d048 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -789,10 +789,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(StartDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(StartDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -801,6 +801,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class StartDateConverter : JsonConverter @@ -1078,10 +1088,10 @@ public override void Validate() ); } - public virtual bool Equals(Discount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Discount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1090,6 +1100,17 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + Amount _ => 0, + Percentage _ => 1, + Usage _ => 2, + _ => -1, + }; + } } sealed class DiscountConverter : JsonConverter @@ -1620,10 +1641,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(EndDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EndDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1632,6 +1653,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EndDateConverter : JsonConverter @@ -3616,10 +3647,10 @@ public override void Validate() ); } - public virtual bool Equals(PriceModel? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModel? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3628,6 +3659,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewFloatingUnitPrice _ => 0, + NewFloatingTieredPrice _ => 1, + NewFloatingBulkPrice _ => 2, + PriceModelBulkWithFilters _ => 3, + NewFloatingPackagePrice _ => 4, + NewFloatingMatrixPrice _ => 5, + NewFloatingThresholdTotalAmountPrice _ => 6, + NewFloatingTieredPackagePrice _ => 7, + NewFloatingTieredWithMinimumPrice _ => 8, + NewFloatingGroupedTieredPrice _ => 9, + NewFloatingTieredPackageWithMinimumPrice _ => 10, + NewFloatingPackageWithAllocationPrice _ => 11, + NewFloatingUnitWithPercentPrice _ => 12, + NewFloatingMatrixWithAllocationPrice _ => 13, + NewFloatingTieredWithProrationPrice _ => 14, + NewFloatingUnitWithProrationPrice _ => 15, + NewFloatingGroupedAllocationPrice _ => 16, + NewFloatingBulkWithProrationPrice _ => 17, + NewFloatingGroupedWithProratedMinimumPrice _ => 18, + NewFloatingGroupedWithMeteredMinimumPrice _ => 19, + PriceModelGroupedWithMinMaxThresholds _ => 20, + NewFloatingMatrixWithDisplayNamePrice _ => 21, + NewFloatingGroupedTieredPackagePrice _ => 22, + NewFloatingMaxGroupTieredPackagePrice _ => 23, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 24, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 25, + NewFloatingCumulativeGroupedBulkPrice _ => 26, + PriceModelCumulativeGroupedAllocation _ => 27, + NewFloatingMinimumCompositePrice _ => 28, + PriceModelPercent _ => 29, + PriceModelEventOutput _ => 30, + _ => -1, + }; + } } sealed class PriceModelConverter : JsonConverter @@ -5233,10 +5303,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceModelBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModelBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5245,6 +5315,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelBulkWithFiltersConversionRateConfigConverter @@ -6027,10 +6107,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6039,6 +6119,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -6821,10 +6911,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceModelCumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModelCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6833,6 +6923,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelCumulativeGroupedAllocationConversionRateConfigConverter @@ -7554,10 +7654,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceModelPercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModelPercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7566,6 +7666,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelPercentConversionRateConfigConverter @@ -8327,10 +8437,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceModelEventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModelEventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8339,6 +8449,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelEventOutputConversionRateConfigConverter @@ -8759,10 +8879,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(SubscriptionPriceIntervalsParamsAddAdjustmentStartDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubscriptionPriceIntervalsParamsAddAdjustmentStartDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8771,6 +8891,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class SubscriptionPriceIntervalsParamsAddAdjustmentStartDateConverter @@ -9175,10 +9305,10 @@ public override void Validate() ); } - public virtual bool Equals(SubscriptionPriceIntervalsParamsAddAdjustmentAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubscriptionPriceIntervalsParamsAddAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9187,6 +9317,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class SubscriptionPriceIntervalsParamsAddAdjustmentAdjustmentConverter @@ -9532,10 +9675,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(SubscriptionPriceIntervalsParamsAddAdjustmentEndDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubscriptionPriceIntervalsParamsAddAdjustmentEndDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9544,6 +9687,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class SubscriptionPriceIntervalsParamsAddAdjustmentEndDateConverter @@ -9980,10 +10133,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(EditEndDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EditEndDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9992,6 +10145,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EditEndDateConverter : JsonConverter @@ -10314,10 +10477,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(EditStartDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EditStartDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10326,6 +10489,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EditStartDateConverter : JsonConverter @@ -10673,10 +10846,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(EditAdjustmentEndDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EditAdjustmentEndDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10685,6 +10858,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EditAdjustmentEndDateConverter : JsonConverter @@ -10930,10 +11113,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(EditAdjustmentStartDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EditAdjustmentStartDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10942,6 +11125,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EditAdjustmentStartDateConverter : JsonConverter diff --git a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs index 1605b646e..6000d8a6a 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -1255,10 +1255,12 @@ public override void Validate() ); } - public virtual bool Equals(SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1267,6 +1269,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentConverter @@ -3740,10 +3755,10 @@ public override void Validate() ); } - public virtual bool Equals(SubscriptionSchedulePlanChangeParamsAddPricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubscriptionSchedulePlanChangeParamsAddPricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3752,6 +3767,45 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewSubscriptionUnitPrice _ => 0, + NewSubscriptionTieredPrice _ => 1, + NewSubscriptionBulkPrice _ => 2, + SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters _ => 3, + NewSubscriptionPackagePrice _ => 4, + NewSubscriptionMatrixPrice _ => 5, + NewSubscriptionThresholdTotalAmountPrice _ => 6, + NewSubscriptionTieredPackagePrice _ => 7, + NewSubscriptionTieredWithMinimumPrice _ => 8, + NewSubscriptionGroupedTieredPrice _ => 9, + NewSubscriptionTieredPackageWithMinimumPrice _ => 10, + NewSubscriptionPackageWithAllocationPrice _ => 11, + NewSubscriptionUnitWithPercentPrice _ => 12, + NewSubscriptionMatrixWithAllocationPrice _ => 13, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds _ => 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation _ => 27, + NewSubscriptionMinimumCompositePrice _ => 28, + SubscriptionSchedulePlanChangeParamsAddPricePricePercent _ => 29, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput _ => 30, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceConverter @@ -5442,10 +5496,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5454,6 +5508,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigConverter @@ -6366,10 +6430,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6378,6 +6442,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigConverter @@ -7219,10 +7293,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7231,6 +7305,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -8072,10 +8156,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8084,6 +8168,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -8864,10 +8958,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8876,6 +8970,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter @@ -9700,10 +9804,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9712,6 +9816,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter @@ -10455,10 +10569,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10467,6 +10581,19 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter @@ -12935,10 +13062,10 @@ public override void Validate() ); } - public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -12947,6 +13074,47 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + NewSubscriptionUnitPrice _ => 0, + NewSubscriptionTieredPrice _ => 1, + NewSubscriptionBulkPrice _ => 2, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters _ => 3, + NewSubscriptionPackagePrice _ => 4, + NewSubscriptionMatrixPrice _ => 5, + NewSubscriptionThresholdTotalAmountPrice _ => 6, + NewSubscriptionTieredPackagePrice _ => 7, + NewSubscriptionTieredWithMinimumPrice _ => 8, + NewSubscriptionGroupedTieredPrice _ => 9, + NewSubscriptionTieredPackageWithMinimumPrice _ => 10, + NewSubscriptionPackageWithAllocationPrice _ => 11, + NewSubscriptionUnitWithPercentPrice _ => 12, + NewSubscriptionMatrixWithAllocationPrice _ => 13, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds _ => + 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation _ => + 27, + NewSubscriptionMinimumCompositePrice _ => 28, + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent _ => 29, + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput _ => 30, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter @@ -14640,10 +14808,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -14652,6 +14820,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter @@ -15566,10 +15744,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -15578,6 +15756,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter @@ -16419,10 +16607,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16431,6 +16619,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -17272,10 +17470,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17284,6 +17482,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -18070,10 +18278,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsReplacePricePricePercentConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -18082,6 +18290,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePricePercentConversionRateConfigConverter @@ -18913,10 +19131,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -18925,6 +19143,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs index 4c89d33c2..4e847e367 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs @@ -374,10 +374,10 @@ public override void Validate() this.Switch((_) => { }, (unionMember1) => unionMember1.Validate()); } - public virtual bool Equals(TrialEndDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TrialEndDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -386,6 +386,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class TrialEndDateConverter : JsonConverter diff --git a/src/Orb/Models/Subscriptions/SubscriptionUsage.cs b/src/Orb/Models/Subscriptions/SubscriptionUsage.cs index 0177eb7d4..f9f3431bd 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUsage.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUsage.cs @@ -189,10 +189,10 @@ public override void Validate() this.Switch((ungrouped) => ungrouped.Validate(), (grouped) => grouped.Validate()); } - public virtual bool Equals(SubscriptionUsage? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubscriptionUsage? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -201,6 +201,16 @@ public override int GetHashCode() public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + int VariantIndex() + { + return this.Value switch + { + UngroupedSubscriptionUsage _ => 0, + GroupedSubscriptionUsage _ => 1, + _ => -1, + }; + } } sealed class SubscriptionUsageConverter : JsonConverter From 89b717cfbece7a4cf336964f84eebe2f9f9a2742 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 02:24:55 +0000 Subject: [PATCH 16/39] feat(api): api update --- .stats.yml | 4 +- .../Alerts/AlertListPageResponseTest.cs | 7 ++ src/Orb.Tests/Models/Alerts/AlertTest.cs | 79 ++++++++++++++++++ src/Orb/Models/Alerts/Alert.cs | 81 +++++++++++++++++++ 4 files changed, 169 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index e572dc254..a6cf36af7 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-9f1a41612765cb08d100b2c9e85080e93306e8d0942d535f16052c3eb18d9b8b.yml -openapi_spec_hash: 6dd28f36adc7e7d6a9245585eaf9b9c1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-931771ff4ab183044ee50ce43ea794ac0a15bfafbaf7df61ac0344af3ff08944.yml +openapi_spec_hash: 71371804e373f662585284bf5d93cc62 config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs b/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs index 844dcd23a..dcfc8cedf 100644 --- a/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs @@ -35,6 +35,7 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -61,6 +62,7 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }, ]; PaginationMetadata expectedPaginationMetadata = new() @@ -103,6 +105,7 @@ public void SerializationRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -143,6 +146,7 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -176,6 +180,7 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }, ]; PaginationMetadata expectedPaginationMetadata = new() @@ -218,6 +223,7 @@ public void Validation_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -252,6 +258,7 @@ public void CopyConstructor_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, diff --git a/src/Orb.Tests/Models/Alerts/AlertTest.cs b/src/Orb.Tests/Models/Alerts/AlertTest.cs index a28d97a9d..5c683247c 100644 --- a/src/Orb.Tests/Models/Alerts/AlertTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertTest.cs @@ -32,6 +32,7 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }; string expectedID = "XuxCbt7x9L82yyeF"; @@ -58,6 +59,7 @@ public void FieldRoundtrip_Works() [ new() { InAlert = true, ThresholdValue = 0 }, ]; + LicenseType expectedLicenseType = new("id"); Assert.Equal(expectedID, model.ID); Assert.Equal(expectedCreatedAt, model.CreatedAt); @@ -80,6 +82,7 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedBalanceAlertStatus[i], model.BalanceAlertStatus[i]); } + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -104,6 +107,7 @@ public void SerializationRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -134,6 +138,7 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -164,6 +169,7 @@ public void FieldRoundtripThroughSerialization_Works() [ new() { InAlert = true, ThresholdValue = 0 }, ]; + LicenseType expectedLicenseType = new("id"); Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); @@ -186,6 +192,7 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedBalanceAlertStatus[i], deserialized.BalanceAlertStatus[i]); } + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -210,6 +217,7 @@ public void Validation_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }; model.Validate(); @@ -240,6 +248,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.BalanceAlertStatus); Assert.False(model.RawData.ContainsKey("balance_alert_status")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -291,10 +301,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = null, + LicenseType = null, }; Assert.Null(model.BalanceAlertStatus); Assert.True(model.RawData.ContainsKey("balance_alert_status")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -320,6 +333,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = null, + LicenseType = null, }; model.Validate(); @@ -347,6 +361,7 @@ public void CopyConstructor_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + LicenseType = new("id"), }; Alert copied = new(model); @@ -517,6 +532,7 @@ public class AlertTypeTest : TestBase [InlineData(AlertType.CreditBalanceRecovered)] [InlineData(AlertType.UsageExceeded)] [InlineData(AlertType.CostExceeded)] + [InlineData(AlertType.LicenseBalanceThresholdReached)] public void Validation_Works(AlertType rawValue) { // force implicit conversion because Theory can't do that for us @@ -542,6 +558,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(AlertType.CreditBalanceRecovered)] [InlineData(AlertType.UsageExceeded)] [InlineData(AlertType.CostExceeded)] + [InlineData(AlertType.LicenseBalanceThresholdReached)] public void SerializationRoundtrip_Works(AlertType rawValue) { // force implicit conversion because Theory can't do that for us @@ -638,3 +655,65 @@ public void CopyConstructor_Works() Assert.Equal(model, copied); } } + +public class LicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseType { ID = "id" }; + + string expectedID = "id"; + + Assert.Equal(expectedID, model.ID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseType { ID = "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 LicenseType { ID = "id" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + + Assert.Equal(expectedID, deserialized.ID); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseType { ID = "id" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseType { ID = "id" }; + + LicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb/Models/Alerts/Alert.cs b/src/Orb/Models/Alerts/Alert.cs index 61b2fefd2..028af9086 100644 --- a/src/Orb/Models/Alerts/Alert.cs +++ b/src/Orb/Models/Alerts/Alert.cs @@ -176,6 +176,19 @@ public IReadOnlyList? BalanceAlertStatus } } + /// + /// Minified license type for alert serialization. + /// + public LicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -196,6 +209,7 @@ public override void Validate() { item.Validate(); } + this.LicenseType?.Validate(); } public Alert() { } @@ -403,6 +417,7 @@ public enum AlertType CreditBalanceRecovered, UsageExceeded, CostExceeded, + LicenseBalanceThresholdReached, } sealed class AlertTypeConverter : JsonConverter @@ -420,6 +435,7 @@ JsonSerializerOptions options "credit_balance_recovered" => AlertType.CreditBalanceRecovered, "usage_exceeded" => AlertType.UsageExceeded, "cost_exceeded" => AlertType.CostExceeded, + "license_balance_threshold_reached" => AlertType.LicenseBalanceThresholdReached, _ => (AlertType)(-1), }; } @@ -439,6 +455,7 @@ JsonSerializerOptions options AlertType.CreditBalanceRecovered => "credit_balance_recovered", AlertType.UsageExceeded => "usage_exceeded", AlertType.CostExceeded => "cost_exceeded", + AlertType.LicenseBalanceThresholdReached => "license_balance_threshold_reached", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -523,3 +540,67 @@ class BalanceAlertStatusFromRaw : IFromRawJson public BalanceAlertStatus FromRawUnchecked(IReadOnlyDictionary rawData) => BalanceAlertStatus.FromRawUnchecked(rawData); } + +/// +/// Minified license type for alert serialization. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseType : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + } + + public LicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseType(LicenseType licenseType) + : base(licenseType) { } +#pragma warning restore CS8618 + + public LicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseType FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public LicenseType(string id) + : this() + { + this.ID = id; + } +} + +class LicenseTypeFromRaw : IFromRawJson +{ + /// + public LicenseType FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseType.FromRawUnchecked(rawData); +} From 830cc0c641572bcc8fdac8b7b754eb7ab10c0f5e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 00:24:52 +0000 Subject: [PATCH 17/39] feat(api): api update --- .stats.yml | 4 +- src/Orb.Tests/Models/AggregatedCostTest.cs | 49 + src/Orb.Tests/Models/Alerts/AlertTest.cs | 10 +- src/Orb.Tests/Models/AllocationTest.cs | 123 + .../Beta/BetaCreatePlanVersionParamsTest.cs | 344 + ...ternalPlanIDCreatePlanVersionParamsTest.cs | 344 + src/Orb.Tests/Models/Beta/PlanVersionTest.cs | 49 + .../ChangedSubscriptionResourcesTest.cs | 196 + .../Costs/CostListByExternalIDResponseTest.cs | 49 + .../Customers/Costs/CostListResponseTest.cs | 49 + .../Ledger/IncrementLedgerEntryTest.cs | 49 + ...dgerCreateEntryByExternalIDResponseTest.cs | 14 + .../Ledger/LedgerCreateEntryResponseTest.cs | 14 + .../LedgerListByExternalIDPageResponseTest.cs | 49 + .../LedgerListByExternalIDResponseTest.cs | 14 + .../Ledger/LedgerListPageResponseTest.cs | 49 + .../Credits/Ledger/LedgerListResponseTest.cs | 14 + .../InvoiceLineItemCreateResponseTest.cs | 49 + src/Orb.Tests/Models/InvoiceTest.cs | 98 + .../InvoiceFetchUpcomingResponseTest.cs | 98 + .../Invoices/InvoiceListPageResponseTest.cs | 49 + .../Models/NewAllocationPriceTest.cs | 19 + .../Models/NewFloatingBulkPriceTest.cs | 15 + .../NewFloatingBulkWithProrationPriceTest.cs | 15 + ...wFloatingCumulativeGroupedBulkPriceTest.cs | 15 + .../NewFloatingGroupedAllocationPriceTest.cs | 15 + ...ewFloatingGroupedTieredPackagePriceTest.cs | 15 + .../NewFloatingGroupedTieredPriceTest.cs | 15 + ...atingGroupedWithMeteredMinimumPriceTest.cs | 15 + ...tingGroupedWithProratedMinimumPriceTest.cs | 15 + .../Models/NewFloatingMatrixPriceTest.cs | 15 + ...ewFloatingMatrixWithAllocationPriceTest.cs | 15 + ...wFloatingMatrixWithDisplayNamePriceTest.cs | 15 + ...wFloatingMaxGroupTieredPackagePriceTest.cs | 15 + .../NewFloatingMinimumCompositePriceTest.cs | 15 + .../Models/NewFloatingPackagePriceTest.cs | 15 + ...wFloatingPackageWithAllocationPriceTest.cs | 15 + ...calableMatrixWithTieredPricingPriceTest.cs | 15 + ...gScalableMatrixWithUnitPricingPriceTest.cs | 15 + ...ewFloatingThresholdTotalAmountPriceTest.cs | 15 + .../NewFloatingTieredPackagePriceTest.cs | 15 + ...oatingTieredPackageWithMinimumPriceTest.cs | 15 + .../Models/NewFloatingTieredPriceTest.cs | 15 + .../NewFloatingTieredWithMinimumPriceTest.cs | 15 + ...NewFloatingTieredWithProrationPriceTest.cs | 15 + .../Models/NewFloatingUnitPriceTest.cs | 15 + .../NewFloatingUnitWithPercentPriceTest.cs | 15 + .../NewFloatingUnitWithProrationPriceTest.cs | 15 + src/Orb.Tests/Models/NewPlanBulkPriceTest.cs | 15 + .../NewPlanBulkWithProrationPriceTest.cs | 15 + .../NewPlanCumulativeGroupedBulkPriceTest.cs | 15 + .../NewPlanGroupedAllocationPriceTest.cs | 15 + .../NewPlanGroupedTieredPackagePriceTest.cs | 15 + .../Models/NewPlanGroupedTieredPriceTest.cs | 15 + ...wPlanGroupedWithMeteredMinimumPriceTest.cs | 15 + ...PlanGroupedWithProratedMinimumPriceTest.cs | 15 + .../Models/NewPlanMatrixPriceTest.cs | 15 + .../NewPlanMatrixWithAllocationPriceTest.cs | 15 + .../NewPlanMatrixWithDisplayNamePriceTest.cs | 15 + .../NewPlanMaxGroupTieredPackagePriceTest.cs | 15 + .../NewPlanMinimumCompositePriceTest.cs | 15 + .../Models/NewPlanPackagePriceTest.cs | 15 + .../NewPlanPackageWithAllocationPriceTest.cs | 15 + ...calableMatrixWithTieredPricingPriceTest.cs | 15 + ...nScalableMatrixWithUnitPricingPriceTest.cs | 15 + .../NewPlanThresholdTotalAmountPriceTest.cs | 15 + .../Models/NewPlanTieredPackagePriceTest.cs | 15 + ...ewPlanTieredPackageWithMinimumPriceTest.cs | 15 + .../Models/NewPlanTieredPriceTest.cs | 15 + .../NewPlanTieredWithMinimumPriceTest.cs | 15 + src/Orb.Tests/Models/NewPlanUnitPriceTest.cs | 15 + .../Models/NewPlanUnitWithPercentPriceTest.cs | 15 + .../NewPlanUnitWithProrationPriceTest.cs | 15 + src/Orb.Tests/Models/PerPriceCostTest.cs | 77 + .../Models/Plans/PlanCreateParamsTest.cs | 182 + .../Models/Plans/PlanListPageResponseTest.cs | 49 + src/Orb.Tests/Models/Plans/PlanTest.cs | 49 + src/Orb.Tests/Models/PriceIntervalTest.cs | 49 + src/Orb.Tests/Models/PriceTest.cs | 8256 ++++++++++++++--- .../Models/Prices/PriceCreateParamsTest.cs | 141 + .../Prices/PriceEvaluateMultipleParamsTest.cs | 153 + .../PriceEvaluatePreviewEventsParamsTest.cs | 153 + .../Prices/PriceListPageResponseTest.cs | 49 + .../MutatedSubscriptionTest.cs | 252 + .../SubscriptionChangeApplyResponseTest.cs | 308 + .../SubscriptionChangeCancelResponseTest.cs | 308 + .../SubscriptionChangeRetrieveResponseTest.cs | 308 + .../NewSubscriptionBulkPriceTest.cs | 15 + ...wSubscriptionBulkWithProrationPriceTest.cs | 15 + ...scriptionCumulativeGroupedBulkPriceTest.cs | 15 + ...wSubscriptionGroupedAllocationPriceTest.cs | 15 + ...bscriptionGroupedTieredPackagePriceTest.cs | 15 + .../NewSubscriptionGroupedTieredPriceTest.cs | 15 + ...ptionGroupedWithMeteredMinimumPriceTest.cs | 15 + ...tionGroupedWithProratedMinimumPriceTest.cs | 15 + .../NewSubscriptionMatrixPriceTest.cs | 15 + ...bscriptionMatrixWithAllocationPriceTest.cs | 15 + ...scriptionMatrixWithDisplayNamePriceTest.cs | 15 + ...scriptionMaxGroupTieredPackagePriceTest.cs | 15 + ...ewSubscriptionMinimumCompositePriceTest.cs | 15 + .../NewSubscriptionPackagePriceTest.cs | 15 + ...scriptionPackageWithAllocationPriceTest.cs | 15 + ...calableMatrixWithTieredPricingPriceTest.cs | 15 + ...nScalableMatrixWithUnitPricingPriceTest.cs | 15 + ...bscriptionThresholdTotalAmountPriceTest.cs | 15 + .../NewSubscriptionTieredPackagePriceTest.cs | 15 + ...iptionTieredPackageWithMinimumPriceTest.cs | 15 + .../NewSubscriptionTieredPriceTest.cs | 15 + ...wSubscriptionTieredWithMinimumPriceTest.cs | 15 + .../NewSubscriptionUnitPriceTest.cs | 15 + ...NewSubscriptionUnitWithPercentPriceTest.cs | 15 + ...wSubscriptionUnitWithProrationPriceTest.cs | 15 + .../SubscriptionCreateParamsTest.cs | 352 + .../SubscriptionFetchCostsResponseTest.cs | 49 + .../SubscriptionPriceIntervalsParamsTest.cs | 161 + ...ubscriptionSchedulePlanChangeParamsTest.cs | 344 + .../SubscriptionSubscriptionsTest.cs | 98 + .../Models/Subscriptions/SubscriptionTest.cs | 98 + src/Orb.Tests/Services/PlanServiceTest.cs | 2 + src/Orb.Tests/Services/PriceServiceTest.cs | 1 + src/Orb/Models/Allocation.cs | 11 + .../Beta/BetaCreatePlanVersionParams.cs | 248 + .../ExternalPlanIDCreatePlanVersionParams.cs | 248 + .../LedgerCreateEntryByExternalIDParams.cs | 3 +- .../Credits/Ledger/LedgerCreateEntryParams.cs | 3 +- src/Orb/Models/NewAllocationPrice.cs | 14 + src/Orb/Models/NewFloatingBulkPrice.cs | 14 + .../NewFloatingBulkWithProrationPrice.cs | 14 + .../NewFloatingCumulativeGroupedBulkPrice.cs | 14 + .../NewFloatingGroupedAllocationPrice.cs | 14 + .../NewFloatingGroupedTieredPackagePrice.cs | 14 + .../Models/NewFloatingGroupedTieredPrice.cs | 14 + ...wFloatingGroupedWithMeteredMinimumPrice.cs | 14 + ...FloatingGroupedWithProratedMinimumPrice.cs | 14 + src/Orb/Models/NewFloatingMatrixPrice.cs | 14 + .../NewFloatingMatrixWithAllocationPrice.cs | 14 + .../NewFloatingMatrixWithDisplayNamePrice.cs | 14 + .../NewFloatingMaxGroupTieredPackagePrice.cs | 14 + .../NewFloatingMinimumCompositePrice.cs | 14 + src/Orb/Models/NewFloatingPackagePrice.cs | 14 + .../NewFloatingPackageWithAllocationPrice.cs | 14 + ...ingScalableMatrixWithTieredPricingPrice.cs | 14 + ...atingScalableMatrixWithUnitPricingPrice.cs | 14 + .../NewFloatingThresholdTotalAmountPrice.cs | 14 + .../Models/NewFloatingTieredPackagePrice.cs | 14 + ...ewFloatingTieredPackageWithMinimumPrice.cs | 14 + src/Orb/Models/NewFloatingTieredPrice.cs | 14 + .../NewFloatingTieredWithMinimumPrice.cs | 14 + .../NewFloatingTieredWithProrationPrice.cs | 14 + src/Orb/Models/NewFloatingUnitPrice.cs | 14 + .../Models/NewFloatingUnitWithPercentPrice.cs | 14 + .../NewFloatingUnitWithProrationPrice.cs | 14 + src/Orb/Models/NewPlanBulkPrice.cs | 14 + .../Models/NewPlanBulkWithProrationPrice.cs | 14 + .../NewPlanCumulativeGroupedBulkPrice.cs | 14 + .../Models/NewPlanGroupedAllocationPrice.cs | 14 + .../NewPlanGroupedTieredPackagePrice.cs | 14 + src/Orb/Models/NewPlanGroupedTieredPrice.cs | 14 + .../NewPlanGroupedWithMeteredMinimumPrice.cs | 14 + .../NewPlanGroupedWithProratedMinimumPrice.cs | 14 + src/Orb/Models/NewPlanMatrixPrice.cs | 14 + .../NewPlanMatrixWithAllocationPrice.cs | 14 + .../NewPlanMatrixWithDisplayNamePrice.cs | 14 + .../NewPlanMaxGroupTieredPackagePrice.cs | 14 + .../Models/NewPlanMinimumCompositePrice.cs | 14 + src/Orb/Models/NewPlanPackagePrice.cs | 14 + .../NewPlanPackageWithAllocationPrice.cs | 14 + ...lanScalableMatrixWithTieredPricingPrice.cs | 14 + ...wPlanScalableMatrixWithUnitPricingPrice.cs | 14 + .../NewPlanThresholdTotalAmountPrice.cs | 14 + src/Orb/Models/NewPlanTieredPackagePrice.cs | 14 + .../NewPlanTieredPackageWithMinimumPrice.cs | 14 + src/Orb/Models/NewPlanTieredPrice.cs | 14 + .../Models/NewPlanTieredWithMinimumPrice.cs | 14 + src/Orb/Models/NewPlanUnitPrice.cs | 14 + src/Orb/Models/NewPlanUnitWithPercentPrice.cs | 14 + .../Models/NewPlanUnitWithProrationPrice.cs | 14 + src/Orb/Models/Plans/PlanCreateParams.cs | 124 + src/Orb/Models/Price.cs | 3547 +++++++ src/Orb/Models/Prices/PriceCreateParams.cs | 110 + .../Prices/PriceEvaluateMultipleParams.cs | 110 + .../PriceEvaluatePreviewEventsParams.cs | 110 + .../Subscriptions/NewSubscriptionBulkPrice.cs | 14 + .../NewSubscriptionBulkWithProrationPrice.cs | 14 + ...wSubscriptionCumulativeGroupedBulkPrice.cs | 14 + .../NewSubscriptionGroupedAllocationPrice.cs | 14 + ...ewSubscriptionGroupedTieredPackagePrice.cs | 14 + .../NewSubscriptionGroupedTieredPrice.cs | 14 + ...scriptionGroupedWithMeteredMinimumPrice.cs | 14 + ...criptionGroupedWithProratedMinimumPrice.cs | 14 + .../NewSubscriptionMatrixPrice.cs | 14 + ...ewSubscriptionMatrixWithAllocationPrice.cs | 14 + ...wSubscriptionMatrixWithDisplayNamePrice.cs | 14 + ...wSubscriptionMaxGroupTieredPackagePrice.cs | 14 + .../NewSubscriptionMinimumCompositePrice.cs | 14 + .../NewSubscriptionPackagePrice.cs | 14 + ...wSubscriptionPackageWithAllocationPrice.cs | 14 + ...ionScalableMatrixWithTieredPricingPrice.cs | 14 + ...ptionScalableMatrixWithUnitPricingPrice.cs | 14 + ...ewSubscriptionThresholdTotalAmountPrice.cs | 14 + .../NewSubscriptionTieredPackagePrice.cs | 14 + ...bscriptionTieredPackageWithMinimumPrice.cs | 14 + .../NewSubscriptionTieredPrice.cs | 14 + .../NewSubscriptionTieredWithMinimumPrice.cs | 14 + .../Subscriptions/NewSubscriptionUnitPrice.cs | 14 + .../NewSubscriptionUnitWithPercentPrice.cs | 14 + .../NewSubscriptionUnitWithProrationPrice.cs | 14 + .../Subscriptions/SubscriptionCreateParams.cs | 248 + .../SubscriptionPriceIntervalsParams.cs | 110 + .../SubscriptionSchedulePlanChangeParams.cs | 248 + .../Customers/Credits/ILedgerService.cs | 8 +- 211 files changed, 19014 insertions(+), 1504 deletions(-) diff --git a/.stats.yml b/.stats.yml index a6cf36af7..a77b80771 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-931771ff4ab183044ee50ce43ea794ac0a15bfafbaf7df61ac0344af3ff08944.yml -openapi_spec_hash: 71371804e373f662585284bf5d93cc62 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6aa83a816c15600a3d6d378d7804a345505c76726059c19369db4e7766a71cbd.yml +openapi_spec_hash: f283d730e5320f9595c3c0a5902f5cbb config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/src/Orb.Tests/Models/AggregatedCostTest.cs b/src/Orb.Tests/Models/AggregatedCostTest.cs index bc941ea2f..8dfb6b09f 100644 --- a/src/Orb.Tests/Models/AggregatedCostTest.cs +++ b/src/Orb.Tests/Models/AggregatedCostTest.cs @@ -63,6 +63,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -130,6 +131,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -192,6 +199,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -259,6 +267,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -337,6 +351,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -404,6 +419,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -481,6 +502,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -548,6 +570,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -617,6 +645,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -684,6 +713,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -762,6 +797,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -829,6 +865,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -900,6 +942,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -967,6 +1010,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", diff --git a/src/Orb.Tests/Models/Alerts/AlertTest.cs b/src/Orb.Tests/Models/Alerts/AlertTest.cs index 5c683247c..f603e84a1 100644 --- a/src/Orb.Tests/Models/Alerts/AlertTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertTest.cs @@ -3,8 +3,8 @@ using System.Text.Json; using Orb.Core; using Orb.Exceptions; -using Orb.Models; using Orb.Models.Alerts; +using Models = Orb.Models; namespace Orb.Tests.Models.Alerts; @@ -38,7 +38,7 @@ public void FieldRoundtrip_Works() string expectedID = "XuxCbt7x9L82yyeF"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedCurrency = "currency"; - CustomerMinified expectedCustomer = new() + Models::CustomerMinified expectedCustomer = new() { ID = "id", ExternalCustomerID = "external_customer_id", @@ -52,7 +52,7 @@ public void FieldRoundtrip_Works() Name = "Example plan", PlanVersion = "plan_version", }; - SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); + Models::SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); List expectedThresholds = [new(0)]; ApiEnum expectedType = AlertType.CreditBalanceDepleted; List expectedBalanceAlertStatus = @@ -148,7 +148,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedID = "XuxCbt7x9L82yyeF"; DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedCurrency = "currency"; - CustomerMinified expectedCustomer = new() + Models::CustomerMinified expectedCustomer = new() { ID = "id", ExternalCustomerID = "external_customer_id", @@ -162,7 +162,7 @@ public void FieldRoundtripThroughSerialization_Works() Name = "Example plan", PlanVersion = "plan_version", }; - SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); + Models::SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); List expectedThresholds = [new(0)]; ApiEnum expectedType = AlertType.CreditBalanceDepleted; List expectedBalanceAlertStatus = diff --git a/src/Orb.Tests/Models/AllocationTest.cs b/src/Orb.Tests/Models/AllocationTest.cs index 331aff215..736458269 100644 --- a/src/Orb.Tests/Models/AllocationTest.cs +++ b/src/Orb.Tests/Models/AllocationTest.cs @@ -29,6 +29,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; bool expectedAllowsRollover = true; @@ -47,6 +48,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ]; + string expectedLicenseTypeID = "license_type_id"; Assert.Equal(expectedAllowsRollover, model.AllowsRollover); Assert.Equal(expectedCurrency, model.Currency); @@ -57,6 +59,7 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedFilters[i], model.Filters[i]); } + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); } [Fact] @@ -80,6 +83,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -112,6 +116,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -137,6 +142,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ]; + string expectedLicenseTypeID = "license_type_id"; Assert.Equal(expectedAllowsRollover, deserialized.AllowsRollover); Assert.Equal(expectedCurrency, deserialized.Currency); @@ -147,6 +153,7 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedFilters[i], deserialized.Filters[i]); } + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); } [Fact] @@ -170,6 +177,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; model.Validate(); @@ -187,6 +195,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Duration = 0, DurationUnit = CustomExpirationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", }; Assert.Null(model.Filters); @@ -205,6 +214,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Duration = 0, DurationUnit = CustomExpirationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", }; model.Validate(); @@ -222,6 +232,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Duration = 0, DurationUnit = CustomExpirationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", // Null should be interpreted as omitted for these properties Filters = null, @@ -243,6 +254,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Duration = 0, DurationUnit = CustomExpirationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", // Null should be interpreted as omitted for these properties Filters = null, @@ -251,6 +263,116 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Allocation + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + }; + + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Allocation + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Allocation + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + + LicenseTypeID = null, + }; + + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Allocation + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + + LicenseTypeID = null, + }; + + model.Validate(); + } + [Fact] public void CopyConstructor_Works() { @@ -272,6 +394,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; Allocation copied = new(model); diff --git a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs index 6e6fd67d4..5ac690a72 100644 --- a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs @@ -70,6 +70,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -109,6 +110,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -171,6 +173,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -210,6 +213,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -272,6 +276,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -311,6 +316,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -378,6 +384,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -417,6 +424,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -589,6 +597,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -628,6 +637,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -690,6 +700,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -729,6 +740,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1411,6 +1423,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1450,6 +1463,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1476,6 +1490,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -1514,6 +1529,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1549,6 +1565,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1588,6 +1605,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1625,6 +1643,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1664,6 +1683,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1697,6 +1717,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -1735,6 +1756,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1770,6 +1792,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1809,6 +1832,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1895,6 +1919,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1934,6 +1959,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1985,6 +2011,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2041,6 +2068,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2085,6 +2113,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2136,6 +2165,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2180,6 +2210,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2229,6 +2260,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2281,6 +2313,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2333,6 +2366,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2396,6 +2430,7 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2448,6 +2483,7 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2511,6 +2547,7 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2560,6 +2597,7 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2604,6 +2642,7 @@ public void NewPlanUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2654,6 +2693,7 @@ public void NewPlanMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2699,6 +2739,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2743,6 +2784,7 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2792,6 +2834,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2841,6 +2884,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2891,6 +2935,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2950,6 +2995,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2999,6 +3045,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3055,6 +3102,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3108,6 +3156,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3161,6 +3210,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3221,6 +3271,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3284,6 +3335,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3340,6 +3392,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3389,6 +3442,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3433,6 +3487,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3476,6 +3531,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3524,6 +3580,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3568,6 +3625,7 @@ public void NewPlanUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3627,6 +3685,7 @@ public void NewPlanTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3674,6 +3733,7 @@ public void NewPlanBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3728,6 +3788,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3775,6 +3836,7 @@ public void NewPlanPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3827,6 +3889,7 @@ public void NewPlanMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3882,6 +3945,7 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3937,6 +4001,7 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4003,6 +4068,7 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4058,6 +4124,7 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4124,6 +4191,7 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4176,6 +4244,7 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4223,6 +4292,7 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4276,6 +4346,7 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4324,6 +4395,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4371,6 +4443,7 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4423,6 +4496,7 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4475,6 +4549,7 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4528,6 +4603,7 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4590,6 +4666,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4642,6 +4719,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4701,6 +4779,7 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4757,6 +4836,7 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4813,6 +4893,7 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4876,6 +4957,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4942,6 +5024,7 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5001,6 +5084,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5053,6 +5137,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5100,6 +5185,7 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5146,6 +5232,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5197,6 +5284,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5254,6 +5342,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5300,6 +5389,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -5319,6 +5409,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5375,6 +5466,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5433,6 +5525,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5486,6 +5579,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -5508,6 +5602,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5564,6 +5659,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5612,6 +5708,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -5669,6 +5767,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5695,6 +5794,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -5730,6 +5831,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5782,6 +5884,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6270,6 +6373,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6311,6 +6415,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6330,6 +6435,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6380,6 +6486,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6432,6 +6539,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6480,6 +6588,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6502,6 +6611,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6552,6 +6662,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6594,6 +6705,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6639,6 +6752,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6665,6 +6779,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6694,6 +6810,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6740,6 +6857,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7117,6 +7235,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7164,6 +7283,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7186,6 +7306,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7240,6 +7361,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7296,6 +7418,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7350,6 +7473,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7375,6 +7499,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7429,6 +7554,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7475,6 +7601,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7528,6 +7656,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7554,6 +7683,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7587,6 +7718,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7637,6 +7769,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7943,6 +8076,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7990,6 +8124,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8012,6 +8147,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8066,6 +8202,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8122,6 +8259,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8176,6 +8314,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8201,6 +8340,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8255,6 +8395,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8301,6 +8442,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8354,6 +8497,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8380,6 +8524,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8413,6 +8559,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8463,6 +8610,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8763,6 +8911,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8801,6 +8950,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8820,6 +8970,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8868,6 +9019,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8915,6 +9067,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8960,6 +9113,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8982,6 +9136,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9030,6 +9185,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9070,6 +9226,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9111,6 +9269,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9137,6 +9296,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9164,6 +9325,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9208,6 +9370,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9467,6 +9630,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9510,6 +9674,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9529,6 +9694,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -9582,6 +9748,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9637,6 +9804,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9687,6 +9855,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9709,6 +9878,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9762,6 +9932,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9807,6 +9978,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9858,6 +10031,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9884,6 +10058,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9916,6 +10092,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9965,6 +10142,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11165,6 +11343,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11204,6 +11383,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11231,6 +11411,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -11269,6 +11450,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11306,6 +11488,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11345,6 +11528,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11386,6 +11570,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11425,6 +11610,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11459,6 +11645,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -11497,6 +11684,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11534,6 +11722,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11573,6 +11762,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11664,6 +11854,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11703,6 +11894,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11754,6 +11946,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11810,6 +12003,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11854,6 +12048,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11905,6 +12100,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11949,6 +12145,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11998,6 +12195,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12050,6 +12248,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12102,6 +12301,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12165,6 +12365,7 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12217,6 +12418,7 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12280,6 +12482,7 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12329,6 +12532,7 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12373,6 +12577,7 @@ public void NewPlanUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12423,6 +12628,7 @@ public void NewPlanMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12468,6 +12674,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12512,6 +12719,7 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12561,6 +12769,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12610,6 +12819,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12660,6 +12870,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12719,6 +12930,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12768,6 +12980,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12824,6 +13037,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12877,6 +13091,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12930,6 +13145,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12990,6 +13206,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13053,6 +13270,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13109,6 +13327,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13158,6 +13377,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13202,6 +13422,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13245,6 +13466,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13293,6 +13515,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13337,6 +13560,7 @@ public void NewPlanUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13399,6 +13623,7 @@ public void NewPlanTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13449,6 +13674,7 @@ public void NewPlanBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13506,6 +13732,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13556,6 +13783,7 @@ public void NewPlanPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13611,6 +13839,7 @@ public void NewPlanMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13669,6 +13898,7 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13727,6 +13957,7 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13796,6 +14027,7 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13854,6 +14086,7 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13923,6 +14156,7 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13978,6 +14212,7 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14028,6 +14263,7 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14084,6 +14320,7 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14135,6 +14372,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14185,6 +14423,7 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14240,6 +14479,7 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14295,6 +14535,7 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14351,6 +14592,7 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14416,6 +14658,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14471,6 +14714,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14533,6 +14777,7 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14592,6 +14837,7 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14651,6 +14897,7 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14717,6 +14964,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14786,6 +15034,7 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14848,6 +15097,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14903,6 +15153,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14953,6 +15204,7 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15002,6 +15254,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15056,6 +15309,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15116,6 +15370,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15163,6 +15418,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -15182,6 +15438,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -15238,6 +15495,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15296,6 +15554,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15350,6 +15609,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -15372,6 +15632,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -15428,6 +15689,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15476,6 +15738,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -15533,6 +15797,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15559,6 +15824,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -15594,6 +15861,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15646,6 +15914,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16206,6 +16475,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16246,6 +16516,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -16265,6 +16536,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -16315,6 +16587,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16367,6 +16640,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16414,6 +16688,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -16436,6 +16711,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -16486,6 +16762,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16528,6 +16805,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -16573,6 +16852,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16599,6 +16879,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -16628,6 +16910,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16674,6 +16957,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17055,6 +17339,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17103,6 +17388,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17125,6 +17411,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -17179,6 +17466,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17235,6 +17523,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17290,6 +17579,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17315,6 +17605,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -17369,6 +17660,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17415,6 +17707,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17468,6 +17762,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17494,6 +17789,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17527,6 +17824,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17577,6 +17875,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17893,6 +18192,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17941,6 +18241,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17963,6 +18264,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -18017,6 +18319,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18073,6 +18376,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18128,6 +18432,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18153,6 +18458,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -18207,6 +18513,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18253,6 +18560,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18306,6 +18615,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18332,6 +18642,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18365,6 +18677,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18415,6 +18728,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18725,6 +19039,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18764,6 +19079,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18783,6 +19099,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -18831,6 +19148,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18881,6 +19199,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18927,6 +19246,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18949,6 +19269,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -18997,6 +19318,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19037,6 +19359,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19078,6 +19402,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19104,6 +19429,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19131,6 +19458,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19175,6 +19503,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19436,6 +19765,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19480,6 +19810,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19499,6 +19830,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -19552,6 +19884,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19607,6 +19940,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19658,6 +19992,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19680,6 +20015,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -19733,6 +20069,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19778,6 +20115,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19829,6 +20168,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19855,6 +20195,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19887,6 +20229,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19936,6 +20279,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs index 3ec961622..94311dd35 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs @@ -70,6 +70,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -109,6 +110,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -171,6 +173,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -210,6 +213,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -272,6 +276,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -311,6 +316,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -378,6 +384,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -417,6 +424,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -600,6 +608,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -639,6 +648,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -701,6 +711,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -740,6 +751,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1422,6 +1434,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1461,6 +1474,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1487,6 +1501,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -1525,6 +1540,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1560,6 +1576,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1599,6 +1616,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1636,6 +1654,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1675,6 +1694,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1708,6 +1728,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -1746,6 +1767,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1781,6 +1803,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1820,6 +1843,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1906,6 +1930,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1945,6 +1970,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1996,6 +2022,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2052,6 +2079,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2096,6 +2124,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2147,6 +2176,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2191,6 +2221,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2240,6 +2271,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2292,6 +2324,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2344,6 +2377,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2407,6 +2441,7 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2459,6 +2494,7 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2522,6 +2558,7 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2571,6 +2608,7 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2615,6 +2653,7 @@ public void NewPlanUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2665,6 +2704,7 @@ public void NewPlanMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2710,6 +2750,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2754,6 +2795,7 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2803,6 +2845,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2852,6 +2895,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2902,6 +2946,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2961,6 +3006,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3010,6 +3056,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3066,6 +3113,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3119,6 +3167,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3172,6 +3221,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3232,6 +3282,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3295,6 +3346,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3351,6 +3403,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3400,6 +3453,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3444,6 +3498,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3487,6 +3542,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3535,6 +3591,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3579,6 +3636,7 @@ public void NewPlanUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3638,6 +3696,7 @@ public void NewPlanTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3685,6 +3744,7 @@ public void NewPlanBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3739,6 +3799,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3786,6 +3847,7 @@ public void NewPlanPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3838,6 +3900,7 @@ public void NewPlanMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3893,6 +3956,7 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3948,6 +4012,7 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4014,6 +4079,7 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4069,6 +4135,7 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4135,6 +4202,7 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4187,6 +4255,7 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4234,6 +4303,7 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4287,6 +4357,7 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4335,6 +4406,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4382,6 +4454,7 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4434,6 +4507,7 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4486,6 +4560,7 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4539,6 +4614,7 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4601,6 +4677,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4653,6 +4730,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4712,6 +4790,7 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4768,6 +4847,7 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4824,6 +4904,7 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4887,6 +4968,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4953,6 +5035,7 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5012,6 +5095,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5064,6 +5148,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5111,6 +5196,7 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5157,6 +5243,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5208,6 +5295,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5265,6 +5353,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5311,6 +5400,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -5330,6 +5420,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5386,6 +5477,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5444,6 +5536,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5497,6 +5590,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -5519,6 +5613,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5575,6 +5670,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5623,6 +5719,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -5680,6 +5778,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5706,6 +5805,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -5741,6 +5842,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5793,6 +5895,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6281,6 +6384,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6322,6 +6426,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6341,6 +6446,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6391,6 +6497,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6443,6 +6550,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6491,6 +6599,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6513,6 +6622,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6563,6 +6673,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6605,6 +6716,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6650,6 +6763,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6676,6 +6790,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6705,6 +6821,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6751,6 +6868,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7128,6 +7246,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7175,6 +7294,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7197,6 +7317,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7251,6 +7372,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7307,6 +7429,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7361,6 +7484,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7386,6 +7510,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7440,6 +7565,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7486,6 +7612,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7539,6 +7667,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7565,6 +7694,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7598,6 +7729,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7648,6 +7780,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7954,6 +8087,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8001,6 +8135,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8023,6 +8158,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8077,6 +8213,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8133,6 +8270,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8187,6 +8325,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8212,6 +8351,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8266,6 +8406,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8312,6 +8453,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8365,6 +8508,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8391,6 +8535,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8424,6 +8570,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8474,6 +8621,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8774,6 +8922,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8812,6 +8961,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8831,6 +8981,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8879,6 +9030,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8926,6 +9078,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8971,6 +9124,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8993,6 +9147,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9041,6 +9196,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9081,6 +9237,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9122,6 +9280,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9148,6 +9307,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9175,6 +9336,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9219,6 +9381,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9478,6 +9641,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9521,6 +9685,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9540,6 +9705,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -9593,6 +9759,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9648,6 +9815,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9698,6 +9866,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9720,6 +9889,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9773,6 +9943,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9818,6 +9989,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9869,6 +10042,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9895,6 +10069,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9927,6 +10103,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9976,6 +10153,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11176,6 +11354,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11215,6 +11394,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11242,6 +11422,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -11280,6 +11461,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11317,6 +11499,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11356,6 +11539,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11397,6 +11581,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11436,6 +11621,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11470,6 +11656,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -11508,6 +11695,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11545,6 +11733,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11584,6 +11773,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11675,6 +11865,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -11714,6 +11905,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -11765,6 +11957,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11821,6 +12014,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11865,6 +12059,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11916,6 +12111,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11960,6 +12156,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12009,6 +12206,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12061,6 +12259,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12113,6 +12312,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12176,6 +12376,7 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12228,6 +12429,7 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12291,6 +12493,7 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12340,6 +12543,7 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12384,6 +12588,7 @@ public void NewPlanUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12434,6 +12639,7 @@ public void NewPlanMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12479,6 +12685,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12523,6 +12730,7 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12572,6 +12780,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12621,6 +12830,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12671,6 +12881,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12730,6 +12941,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12779,6 +12991,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12835,6 +13048,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12888,6 +13102,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12941,6 +13156,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13001,6 +13217,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13064,6 +13281,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13120,6 +13338,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13169,6 +13388,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13213,6 +13433,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13256,6 +13477,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13304,6 +13526,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13348,6 +13571,7 @@ public void NewPlanUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13410,6 +13634,7 @@ public void NewPlanTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13460,6 +13685,7 @@ public void NewPlanBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13517,6 +13743,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13567,6 +13794,7 @@ public void NewPlanPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13622,6 +13850,7 @@ public void NewPlanMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13680,6 +13909,7 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13738,6 +13968,7 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13807,6 +14038,7 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13865,6 +14097,7 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13934,6 +14167,7 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13989,6 +14223,7 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14039,6 +14274,7 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14095,6 +14331,7 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14146,6 +14383,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14196,6 +14434,7 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14251,6 +14490,7 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14306,6 +14546,7 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14362,6 +14603,7 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14427,6 +14669,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14482,6 +14725,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14544,6 +14788,7 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14603,6 +14848,7 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14662,6 +14908,7 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14728,6 +14975,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14797,6 +15045,7 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14859,6 +15108,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14914,6 +15164,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14964,6 +15215,7 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15013,6 +15265,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15067,6 +15320,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15127,6 +15381,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15174,6 +15429,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -15193,6 +15449,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -15249,6 +15506,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15307,6 +15565,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15361,6 +15620,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -15383,6 +15643,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -15439,6 +15700,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15487,6 +15749,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -15544,6 +15808,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15570,6 +15835,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -15605,6 +15872,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15657,6 +15925,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16217,6 +16486,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16257,6 +16527,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -16276,6 +16547,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -16326,6 +16598,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16378,6 +16651,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16425,6 +16699,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -16447,6 +16722,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -16497,6 +16773,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16539,6 +16816,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -16584,6 +16863,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16610,6 +16890,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -16639,6 +16921,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16685,6 +16968,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17066,6 +17350,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17114,6 +17399,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17136,6 +17422,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -17190,6 +17477,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17246,6 +17534,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17301,6 +17590,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17326,6 +17616,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -17380,6 +17671,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17426,6 +17718,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17479,6 +17773,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17505,6 +17800,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17538,6 +17835,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17588,6 +17886,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17904,6 +18203,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17952,6 +18252,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17974,6 +18275,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -18028,6 +18330,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18084,6 +18387,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18139,6 +18443,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18164,6 +18469,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -18218,6 +18524,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18264,6 +18571,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18317,6 +18626,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18343,6 +18653,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18376,6 +18688,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18426,6 +18739,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18736,6 +19050,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18775,6 +19090,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18794,6 +19110,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -18842,6 +19159,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18892,6 +19210,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18938,6 +19257,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18960,6 +19280,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -19008,6 +19329,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19048,6 +19370,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19089,6 +19413,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19115,6 +19440,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19142,6 +19469,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19186,6 +19514,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19447,6 +19776,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19491,6 +19821,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19510,6 +19841,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -19563,6 +19895,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19618,6 +19951,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19669,6 +20003,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19691,6 +20026,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -19744,6 +20080,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19789,6 +20126,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19840,6 +20179,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19866,6 +20206,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19898,6 +20240,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19947,6 +20290,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Beta/PlanVersionTest.cs b/src/Orb.Tests/Models/Beta/PlanVersionTest.cs index 1ced2437d..1d5d72adf 100644 --- a/src/Orb.Tests/Models/Beta/PlanVersionTest.cs +++ b/src/Orb.Tests/Models/Beta/PlanVersionTest.cs @@ -100,6 +100,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -167,6 +168,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Version = 0, @@ -257,6 +264,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -324,6 +332,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ]; long expectedVersion = 0; @@ -439,6 +453,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -506,6 +521,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Version = 0, @@ -611,6 +632,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -678,6 +700,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Version = 0, @@ -775,6 +803,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -842,6 +871,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ]; long expectedVersion = 0; @@ -957,6 +992,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1024,6 +1060,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Version = 0, @@ -1123,6 +1165,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1190,6 +1233,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Version = 0, diff --git a/src/Orb.Tests/Models/ChangedSubscriptionResourcesTest.cs b/src/Orb.Tests/Models/ChangedSubscriptionResourcesTest.cs index 59d0add06..26a9936bd 100644 --- a/src/Orb.Tests/Models/ChangedSubscriptionResourcesTest.cs +++ b/src/Orb.Tests/Models/ChangedSubscriptionResourcesTest.cs @@ -264,6 +264,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -333,6 +334,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -680,6 +687,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -749,6 +757,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1097,6 +1111,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1165,6 +1180,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1510,6 +1531,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1578,6 +1600,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1953,6 +1981,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2022,6 +2051,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2369,6 +2404,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2438,6 +2474,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2801,6 +2843,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2870,6 +2913,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3217,6 +3266,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3286,6 +3336,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3641,6 +3697,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3709,6 +3766,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4054,6 +4117,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4122,6 +4186,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4497,6 +4567,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4566,6 +4637,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4913,6 +4990,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4982,6 +5060,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -5339,6 +5423,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5408,6 +5493,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -5755,6 +5846,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5824,6 +5916,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6107,6 +6205,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6174,6 +6273,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6447,6 +6552,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6514,6 +6620,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6861,6 +6973,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6928,6 +7041,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -7210,6 +7329,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7277,6 +7397,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -7557,6 +7683,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7624,6 +7751,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -7971,6 +8104,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8038,6 +8172,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -8314,6 +8454,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8381,6 +8522,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9160,6 +9307,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9227,6 +9375,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9334,6 +9488,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9401,6 +9556,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; double expectedQuantity = 1; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"); @@ -9550,6 +9711,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9617,6 +9779,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9740,6 +9908,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9807,6 +9976,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9921,6 +10096,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9988,6 +10164,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; double expectedQuantity = 1; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"); @@ -10137,6 +10319,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10204,6 +10387,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -10321,6 +10510,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10388,6 +10578,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs index 24478306c..6d3640bd0 100644 --- a/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs @@ -68,6 +68,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -135,6 +136,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -204,6 +211,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -271,6 +279,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -351,6 +365,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -418,6 +433,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -501,6 +522,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -568,6 +590,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -644,6 +672,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -711,6 +740,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -791,6 +826,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -858,6 +894,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -935,6 +977,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1002,6 +1045,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", diff --git a/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs b/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs index e7e762d50..2276aeee0 100644 --- a/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs @@ -68,6 +68,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -135,6 +136,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -204,6 +211,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -271,6 +279,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -351,6 +365,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -418,6 +433,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -501,6 +522,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -568,6 +590,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -644,6 +672,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -711,6 +740,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -791,6 +826,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -858,6 +894,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -935,6 +977,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1002,6 +1045,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/IncrementLedgerEntryTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/IncrementLedgerEntryTest.cs index dd005a589..a990594d0 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/IncrementLedgerEntryTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/IncrementLedgerEntryTest.cs @@ -218,6 +218,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -287,6 +288,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -593,6 +600,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -661,6 +669,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -994,6 +1008,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1063,6 +1078,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1379,6 +1400,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1448,6 +1470,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1761,6 +1789,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1829,6 +1858,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2162,6 +2197,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2231,6 +2267,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2695,6 +2737,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2764,6 +2807,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponseTest.cs index d7ed629d0..e402ca0b4 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponseTest.cs @@ -217,6 +217,7 @@ public void IncrementLedgerEntryValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -286,6 +287,12 @@ public void IncrementLedgerEntryValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -820,6 +827,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -889,6 +897,12 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryResponseTest.cs index c5e42d937..1f957c16e 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryResponseTest.cs @@ -217,6 +217,7 @@ public void IncrementLedgerEntryValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -286,6 +287,12 @@ public void IncrementLedgerEntryValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -820,6 +827,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -889,6 +897,12 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponseTest.cs index d86e60ef3..df1800992 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponseTest.cs @@ -234,6 +234,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -317,6 +318,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -632,6 +639,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -713,6 +721,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1052,6 +1066,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1135,6 +1150,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1472,6 +1493,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1555,6 +1577,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1877,6 +1905,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1958,6 +1987,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2297,6 +2332,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2380,6 +2416,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2711,6 +2753,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2794,6 +2837,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponseTest.cs index 02da8c726..deba7fdb8 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponseTest.cs @@ -217,6 +217,7 @@ public void IncrementLedgerEntryValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -286,6 +287,12 @@ public void IncrementLedgerEntryValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -820,6 +827,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -889,6 +897,12 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListPageResponseTest.cs index 8d8a04899..b6245a025 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListPageResponseTest.cs @@ -234,6 +234,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -317,6 +318,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -632,6 +639,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -713,6 +721,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1052,6 +1066,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1135,6 +1150,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1472,6 +1493,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1555,6 +1577,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1877,6 +1905,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1958,6 +1987,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2297,6 +2332,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2380,6 +2416,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2711,6 +2753,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2794,6 +2837,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListResponseTest.cs index 1ea27aa29..73551c94c 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListResponseTest.cs @@ -217,6 +217,7 @@ public void IncrementLedgerEntryValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -286,6 +287,12 @@ public void IncrementLedgerEntryValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -820,6 +827,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -889,6 +897,12 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs b/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs index fe397b828..50460ec98 100644 --- a/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs +++ b/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs @@ -94,6 +94,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -161,6 +162,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -268,6 +275,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -335,6 +343,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; double expectedQuantity = 1; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"); @@ -484,6 +498,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -551,6 +566,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -674,6 +695,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -741,6 +763,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -855,6 +883,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -922,6 +951,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; double expectedQuantity = 1; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"); @@ -1071,6 +1106,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1138,6 +1174,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1255,6 +1297,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1322,6 +1365,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/InvoiceTest.cs b/src/Orb.Tests/Models/InvoiceTest.cs index ee2988d89..dd0852f25 100644 --- a/src/Orb.Tests/Models/InvoiceTest.cs +++ b/src/Orb.Tests/Models/InvoiceTest.cs @@ -183,6 +183,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -250,6 +251,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -520,6 +527,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -587,6 +595,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -931,6 +945,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -998,6 +1013,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1275,6 +1296,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1342,6 +1364,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1619,6 +1647,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1686,6 +1715,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2030,6 +2065,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2097,6 +2133,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2371,6 +2413,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2438,6 +2481,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3206,6 +3255,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3273,6 +3323,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3375,6 +3431,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3438,6 +3495,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; double expectedQuantity = 1; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"); @@ -3580,6 +3643,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3647,6 +3711,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3763,6 +3833,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3830,6 +3901,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3939,6 +4016,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4002,6 +4080,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; double expectedQuantity = 1; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"); @@ -4144,6 +4228,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4211,6 +4296,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4321,6 +4412,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4388,6 +4480,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs index f76bd64b9..5c387ffec 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs @@ -183,6 +183,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -250,6 +251,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -520,6 +527,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -587,6 +595,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -932,6 +946,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -999,6 +1014,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1279,6 +1300,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1346,6 +1368,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1623,6 +1651,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1690,6 +1719,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2035,6 +2070,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2102,6 +2138,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2376,6 +2418,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2443,6 +2486,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3216,6 +3265,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3283,6 +3333,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3385,6 +3441,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3448,6 +3505,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; double expectedQuantity = 1; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"); @@ -3590,6 +3653,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3657,6 +3721,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3774,6 +3844,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3841,6 +3912,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3951,6 +4028,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4014,6 +4092,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; double expectedQuantity = 1; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"); @@ -4156,6 +4240,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4223,6 +4308,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4333,6 +4424,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4400,6 +4492,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs index e2fd330f0..66384ded0 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs @@ -189,6 +189,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -256,6 +257,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -529,6 +536,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -596,6 +604,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -887,6 +901,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -954,6 +969,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1243,6 +1264,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1310,6 +1332,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1590,6 +1618,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1657,6 +1686,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1948,6 +1983,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2015,6 +2051,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2298,6 +2340,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2365,6 +2408,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/NewAllocationPriceTest.cs b/src/Orb.Tests/Models/NewAllocationPriceTest.cs index ca3fd21fa..cc5ba3e5b 100644 --- a/src/Orb.Tests/Models/NewAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewAllocationPriceTest.cs @@ -32,6 +32,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; @@ -54,6 +55,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedItemID = "item_id"; + string expectedLicenseTypeID = "license_type_id"; string expectedPerUnitCostBasis = "per_unit_cost_basis"; Assert.Equal(expectedAmount, model.Amount); @@ -68,6 +70,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFilters[i], model.Filters[i]); } Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.Equal(expectedPerUnitCostBasis, model.PerUnitCostBasis); } @@ -95,6 +98,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; @@ -131,6 +135,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; @@ -160,6 +165,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedItemID = "item_id"; + string expectedLicenseTypeID = "license_type_id"; string expectedPerUnitCostBasis = "per_unit_cost_basis"; Assert.Equal(expectedAmount, deserialized.Amount); @@ -174,6 +180,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFilters[i], deserialized.Filters[i]); } Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.Equal(expectedPerUnitCostBasis, deserialized.PerUnitCostBasis); } @@ -201,6 +208,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; @@ -231,6 +239,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", }; Assert.Null(model.PerUnitCostBasis); @@ -261,6 +270,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", }; model.Validate(); @@ -290,6 +300,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", // Null should be interpreted as omitted for these properties PerUnitCostBasis = null, @@ -323,6 +334,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", // Null should be interpreted as omitted for these properties PerUnitCostBasis = null, @@ -350,6 +362,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("filters")); Assert.Null(model.ItemID); Assert.False(model.RawData.ContainsKey("item_id")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); } [Fact] @@ -380,6 +394,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExpiresAtEndOfCadence = null, Filters = null, ItemID = null, + LicenseTypeID = null, }; Assert.Null(model.CustomExpiration); @@ -390,6 +405,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("filters")); Assert.Null(model.ItemID); Assert.True(model.RawData.ContainsKey("item_id")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); } [Fact] @@ -406,6 +423,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExpiresAtEndOfCadence = null, Filters = null, ItemID = null, + LicenseTypeID = null, }; model.Validate(); @@ -435,6 +453,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; diff --git a/src/Orb.Tests/Models/NewFloatingBulkPriceTest.cs b/src/Orb.Tests/Models/NewFloatingBulkPriceTest.cs index 42a0b1161..55442e378 100644 --- a/src/Orb.Tests/Models/NewFloatingBulkPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingBulkPriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -85,6 +86,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkConfig, model.BulkConfig); @@ -103,6 +105,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -151,6 +154,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -201,6 +205,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -247,6 +252,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkConfig, deserialized.BulkConfig); @@ -268,6 +274,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -316,6 +323,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -355,6 +363,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -397,6 +407,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -420,6 +431,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -446,6 +459,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -490,6 +504,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingBulkWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingBulkWithProrationPriceTest.cs index dc319ab6e..2b5eebf3c 100644 --- a/src/Orb.Tests/Models/NewFloatingBulkWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingBulkWithProrationPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -95,6 +96,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithProrationConfig, model.BulkWithProrationConfig); @@ -113,6 +115,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -166,6 +169,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -221,6 +225,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -272,6 +277,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithProrationConfig, deserialized.BulkWithProrationConfig); @@ -293,6 +299,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -346,6 +353,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -390,6 +398,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -442,6 +452,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -465,6 +476,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -496,6 +509,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -545,6 +559,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingCumulativeGroupedBulkPriceTest.cs b/src/Orb.Tests/Models/NewFloatingCumulativeGroupedBulkPriceTest.cs index 44be2e9db..33378c70b 100644 --- a/src/Orb.Tests/Models/NewFloatingCumulativeGroupedBulkPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingCumulativeGroupedBulkPriceTest.cs @@ -58,6 +58,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -109,6 +110,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -127,6 +129,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -187,6 +190,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -249,6 +253,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -307,6 +312,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -328,6 +334,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -388,6 +395,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -439,6 +447,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -505,6 +515,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -528,6 +539,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -566,6 +579,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -622,6 +636,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingGroupedAllocationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedAllocationPriceTest.cs index 9de25e6b5..25e55b657 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedAllocationPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -95,6 +96,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -113,6 +115,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -166,6 +169,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -221,6 +225,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -272,6 +277,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -293,6 +299,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -346,6 +353,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -390,6 +398,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -442,6 +452,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -465,6 +476,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -496,6 +509,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -545,6 +559,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingGroupedTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedTieredPackagePriceTest.cs index d1f29a391..3466eee17 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedTieredPackagePriceTest.cs @@ -55,6 +55,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -103,6 +104,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -121,6 +123,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -178,6 +181,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -237,6 +241,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -292,6 +297,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -313,6 +319,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -370,6 +377,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -418,6 +426,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -478,6 +488,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -501,6 +512,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -536,6 +549,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -589,6 +603,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingGroupedTieredPriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedTieredPriceTest.cs index cd14ea0f0..5fc321890 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedTieredPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedTieredPriceTest.cs @@ -54,6 +54,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -101,6 +102,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -119,6 +121,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -175,6 +178,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -233,6 +237,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -287,6 +292,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -308,6 +314,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -364,6 +371,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -411,6 +419,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -469,6 +479,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -492,6 +503,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -526,6 +539,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -578,6 +592,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingGroupedWithMeteredMinimumPriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedWithMeteredMinimumPriceTest.cs index 520ab91b1..eb1dfdfda 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedWithMeteredMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedWithMeteredMinimumPriceTest.cs @@ -61,6 +61,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -114,6 +115,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -135,6 +137,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -198,6 +201,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -263,6 +267,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -323,6 +328,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -347,6 +353,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -410,6 +417,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -464,6 +472,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -536,6 +546,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -559,6 +570,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -600,6 +613,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -659,6 +673,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingGroupedWithProratedMinimumPriceTest.cs b/src/Orb.Tests/Models/NewFloatingGroupedWithProratedMinimumPriceTest.cs index a310707ed..8ef48e9ce 100644 --- a/src/Orb.Tests/Models/NewFloatingGroupedWithProratedMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingGroupedWithProratedMinimumPriceTest.cs @@ -52,6 +52,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -96,6 +97,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -117,6 +119,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -171,6 +174,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -227,6 +231,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -278,6 +283,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -302,6 +308,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -356,6 +363,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -401,6 +409,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -455,6 +465,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -478,6 +489,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -510,6 +523,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -560,6 +574,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingMatrixPriceTest.cs b/src/Orb.Tests/Models/NewFloatingMatrixPriceTest.cs index d65f39411..bcf6aa04c 100644 --- a/src/Orb.Tests/Models/NewFloatingMatrixPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMatrixPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -95,6 +96,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -113,6 +115,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -166,6 +169,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -221,6 +225,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -272,6 +277,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -293,6 +299,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -346,6 +353,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -390,6 +398,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -442,6 +452,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -465,6 +476,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -496,6 +509,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -545,6 +559,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingMatrixWithAllocationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingMatrixWithAllocationPriceTest.cs index 80d259b1a..39ddd4f04 100644 --- a/src/Orb.Tests/Models/NewFloatingMatrixWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMatrixWithAllocationPriceTest.cs @@ -52,6 +52,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -97,6 +98,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -115,6 +117,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -169,6 +172,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -225,6 +229,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -277,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -298,6 +304,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -352,6 +359,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -397,6 +405,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -451,6 +461,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -474,6 +485,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -506,6 +519,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -556,6 +570,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingMatrixWithDisplayNamePriceTest.cs b/src/Orb.Tests/Models/NewFloatingMatrixWithDisplayNamePriceTest.cs index 45263ef37..78543c35a 100644 --- a/src/Orb.Tests/Models/NewFloatingMatrixWithDisplayNamePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMatrixWithDisplayNamePriceTest.cs @@ -58,6 +58,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -109,6 +110,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -127,6 +129,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -187,6 +190,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -249,6 +253,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -307,6 +312,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -328,6 +334,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -388,6 +395,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -439,6 +447,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -505,6 +515,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -528,6 +539,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -566,6 +579,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -622,6 +636,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingMaxGroupTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewFloatingMaxGroupTieredPackagePriceTest.cs index 60a2e9702..ae3a0a1d2 100644 --- a/src/Orb.Tests/Models/NewFloatingMaxGroupTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMaxGroupTieredPackagePriceTest.cs @@ -55,6 +55,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -103,6 +104,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -121,6 +123,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -178,6 +181,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -237,6 +241,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -292,6 +297,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -313,6 +319,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -370,6 +377,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -418,6 +426,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -478,6 +488,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -501,6 +512,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -536,6 +549,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -589,6 +603,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingMinimumCompositePriceTest.cs b/src/Orb.Tests/Models/NewFloatingMinimumCompositePriceTest.cs index 0a1310731..63240c0aa 100644 --- a/src/Orb.Tests/Models/NewFloatingMinimumCompositePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingMinimumCompositePriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -89,6 +90,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -107,6 +109,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -155,6 +158,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -205,6 +209,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -255,6 +260,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -276,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -324,6 +331,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -363,6 +371,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -405,6 +415,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -428,6 +439,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -454,6 +467,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -498,6 +512,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingPackagePriceTest.cs b/src/Orb.Tests/Models/NewFloatingPackagePriceTest.cs index d96f07c8b..79737dbb3 100644 --- a/src/Orb.Tests/Models/NewFloatingPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingPackagePriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -89,6 +90,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -107,6 +109,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -155,6 +158,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -205,6 +209,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -255,6 +260,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -276,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -324,6 +331,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -363,6 +371,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -405,6 +415,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -428,6 +439,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -454,6 +467,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -498,6 +512,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingPackageWithAllocationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingPackageWithAllocationPriceTest.cs index 71371203a..975eec36e 100644 --- a/src/Orb.Tests/Models/NewFloatingPackageWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingPackageWithAllocationPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -95,6 +96,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -113,6 +115,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -166,6 +169,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -221,6 +225,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -272,6 +277,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -293,6 +299,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -346,6 +353,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -390,6 +398,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -442,6 +452,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -465,6 +476,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -496,6 +509,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -545,6 +559,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithTieredPricingPriceTest.cs b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithTieredPricingPriceTest.cs index 36d6b221c..15036e5da 100644 --- a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithTieredPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithTieredPricingPriceTest.cs @@ -65,6 +65,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -125,6 +126,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -146,6 +148,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -213,6 +216,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -283,6 +287,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -351,6 +356,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -375,6 +381,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -442,6 +449,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -500,6 +508,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -580,6 +590,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -603,6 +614,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -648,6 +661,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -711,6 +725,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs index 12c1fdd6f..818a6de33 100644 --- a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs @@ -62,6 +62,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -116,6 +117,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -137,6 +139,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -201,6 +204,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -268,6 +272,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -330,6 +335,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -354,6 +360,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -418,6 +425,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -473,6 +481,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -547,6 +557,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -570,6 +581,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -612,6 +625,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -672,6 +686,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingThresholdTotalAmountPriceTest.cs b/src/Orb.Tests/Models/NewFloatingThresholdTotalAmountPriceTest.cs index 6c58b1c0e..cf2a07d0d 100644 --- a/src/Orb.Tests/Models/NewFloatingThresholdTotalAmountPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingThresholdTotalAmountPriceTest.cs @@ -54,6 +54,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -101,6 +102,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -119,6 +121,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -175,6 +178,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -233,6 +237,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -287,6 +292,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -308,6 +314,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -364,6 +371,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -411,6 +419,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -469,6 +479,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -492,6 +503,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -526,6 +539,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -578,6 +592,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredPackagePriceTest.cs index fe026846b..e18c4ac07 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredPackagePriceTest.cs @@ -54,6 +54,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -101,6 +102,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -119,6 +121,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -175,6 +178,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -233,6 +237,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -287,6 +292,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -308,6 +314,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -364,6 +371,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -411,6 +419,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -469,6 +479,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -492,6 +503,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -526,6 +539,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -578,6 +592,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingTieredPackageWithMinimumPriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredPackageWithMinimumPriceTest.cs index 43546d984..7d12fb568 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredPackageWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredPackageWithMinimumPriceTest.cs @@ -64,6 +64,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -121,6 +122,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -139,6 +141,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -205,6 +208,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -273,6 +277,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -337,6 +342,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -361,6 +367,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -427,6 +434,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -484,6 +492,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -562,6 +572,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -585,6 +596,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -629,6 +642,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -691,6 +705,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingTieredPriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredPriceTest.cs index dd9e298fa..687a64678 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredPriceTest.cs @@ -58,6 +58,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -109,6 +110,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -127,6 +129,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -187,6 +190,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -249,6 +253,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -307,6 +312,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -328,6 +334,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -388,6 +395,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -439,6 +447,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -505,6 +515,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -528,6 +539,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -566,6 +579,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -622,6 +636,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingTieredWithMinimumPriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredWithMinimumPriceTest.cs index c6c576e1e..758c7286f 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredWithMinimumPriceTest.cs @@ -65,6 +65,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -123,6 +124,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -141,6 +143,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -208,6 +211,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -277,6 +281,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -342,6 +347,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -363,6 +369,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -430,6 +437,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -488,6 +496,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -568,6 +578,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -591,6 +602,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -636,6 +649,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -699,6 +713,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingTieredWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingTieredWithProrationPriceTest.cs index 83087aeee..3e238957b 100644 --- a/src/Orb.Tests/Models/NewFloatingTieredWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingTieredWithProrationPriceTest.cs @@ -48,6 +48,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -89,6 +90,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -107,6 +109,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -157,6 +160,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -209,6 +213,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -257,6 +262,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -278,6 +284,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -328,6 +335,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -369,6 +377,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -415,6 +425,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -438,6 +449,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -466,6 +479,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -512,6 +526,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingUnitPriceTest.cs b/src/Orb.Tests/Models/NewFloatingUnitPriceTest.cs index cde41dba0..7e8f3c86c 100644 --- a/src/Orb.Tests/Models/NewFloatingUnitPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingUnitPriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -85,6 +86,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -103,6 +105,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -151,6 +154,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -201,6 +205,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -247,6 +252,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -268,6 +274,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -316,6 +323,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -355,6 +363,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -397,6 +407,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -420,6 +431,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -446,6 +459,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -490,6 +504,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingUnitWithPercentPriceTest.cs b/src/Orb.Tests/Models/NewFloatingUnitWithPercentPriceTest.cs index af7592992..02a96d366 100644 --- a/src/Orb.Tests/Models/NewFloatingUnitWithPercentPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingUnitWithPercentPriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -89,6 +90,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -107,6 +109,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -155,6 +158,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -205,6 +209,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -255,6 +260,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -276,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -324,6 +331,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -363,6 +371,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -405,6 +415,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -428,6 +439,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -454,6 +467,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -498,6 +512,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewFloatingUnitWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewFloatingUnitWithProrationPriceTest.cs index 9135900d6..8e68e681a 100644 --- a/src/Orb.Tests/Models/NewFloatingUnitWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingUnitWithProrationPriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -85,6 +86,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -103,6 +105,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -151,6 +154,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -201,6 +205,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -247,6 +252,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -268,6 +274,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -316,6 +323,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -355,6 +363,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -397,6 +407,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -420,6 +431,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -446,6 +459,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -490,6 +504,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/NewPlanBulkPriceTest.cs b/src/Orb.Tests/Models/NewPlanBulkPriceTest.cs index 8601928d8..176c08a90 100644 --- a/src/Orb.Tests/Models/NewPlanBulkPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanBulkPriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -87,6 +88,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -106,6 +108,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -155,6 +158,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -206,6 +210,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -254,6 +259,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -276,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -325,6 +332,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -366,6 +374,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -409,6 +419,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -435,6 +446,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -463,6 +476,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -508,6 +522,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanBulkWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewPlanBulkWithProrationPriceTest.cs index 61b28c016..7d7857513 100644 --- a/src/Orb.Tests/Models/NewPlanBulkWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanBulkWithProrationPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -96,6 +97,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -115,6 +117,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -169,6 +172,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -225,6 +229,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -277,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -299,6 +305,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -353,6 +360,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -399,6 +407,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -452,6 +462,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -478,6 +489,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -511,6 +524,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -561,6 +575,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanCumulativeGroupedBulkPriceTest.cs b/src/Orb.Tests/Models/NewPlanCumulativeGroupedBulkPriceTest.cs index ae78b341e..f35f5247e 100644 --- a/src/Orb.Tests/Models/NewPlanCumulativeGroupedBulkPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanCumulativeGroupedBulkPriceTest.cs @@ -58,6 +58,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -111,6 +112,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -130,6 +132,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -191,6 +194,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -254,6 +258,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -314,6 +319,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -336,6 +342,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -397,6 +404,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -450,6 +458,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -517,6 +527,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -543,6 +554,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -583,6 +596,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -640,6 +654,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanGroupedAllocationPriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedAllocationPriceTest.cs index 375f065a7..aa2b411d5 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedAllocationPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -96,6 +97,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -115,6 +117,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -169,6 +172,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -225,6 +229,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -277,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -299,6 +305,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -353,6 +360,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -399,6 +407,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -452,6 +462,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -478,6 +489,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -511,6 +524,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -561,6 +575,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanGroupedTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedTieredPackagePriceTest.cs index d2bf7eb56..a52e5f81b 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedTieredPackagePriceTest.cs @@ -55,6 +55,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -105,6 +106,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -124,6 +126,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -182,6 +185,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -242,6 +246,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -299,6 +304,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -321,6 +327,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -379,6 +386,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -429,6 +437,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -490,6 +500,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -516,6 +527,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -553,6 +566,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -607,6 +621,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanGroupedTieredPriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedTieredPriceTest.cs index 19961073e..0fb1d58a3 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedTieredPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedTieredPriceTest.cs @@ -54,6 +54,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -102,6 +103,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -121,6 +123,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -178,6 +181,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -237,6 +241,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -292,6 +297,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -314,6 +320,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -371,6 +378,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -420,6 +428,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -479,6 +489,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -505,6 +516,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -541,6 +554,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -594,6 +608,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanGroupedWithMeteredMinimumPriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedWithMeteredMinimumPriceTest.cs index dd8af0c5b..1f7200751 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedWithMeteredMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedWithMeteredMinimumPriceTest.cs @@ -60,6 +60,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -115,6 +116,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -137,6 +139,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -200,6 +203,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -265,6 +269,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -327,6 +332,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -352,6 +358,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -415,6 +422,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -470,6 +478,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -541,6 +551,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -567,6 +578,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -609,6 +622,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -668,6 +682,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanGroupedWithProratedMinimumPriceTest.cs b/src/Orb.Tests/Models/NewPlanGroupedWithProratedMinimumPriceTest.cs index 38ef831da..6bef7e12e 100644 --- a/src/Orb.Tests/Models/NewPlanGroupedWithProratedMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanGroupedWithProratedMinimumPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -97,6 +98,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -119,6 +121,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -173,6 +176,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -229,6 +233,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -282,6 +287,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -307,6 +313,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -361,6 +368,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -407,6 +415,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -460,6 +470,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -486,6 +497,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -519,6 +532,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -569,6 +583,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanMatrixPriceTest.cs b/src/Orb.Tests/Models/NewPlanMatrixPriceTest.cs index af5014ab7..0c7404d4f 100644 --- a/src/Orb.Tests/Models/NewPlanMatrixPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMatrixPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -96,6 +97,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -115,6 +117,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -169,6 +172,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -225,6 +229,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -277,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -299,6 +305,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -353,6 +360,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -399,6 +407,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -452,6 +462,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -478,6 +489,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -511,6 +524,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -561,6 +575,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanMatrixWithAllocationPriceTest.cs b/src/Orb.Tests/Models/NewPlanMatrixWithAllocationPriceTest.cs index 9108837e1..f0a5ae903 100644 --- a/src/Orb.Tests/Models/NewPlanMatrixWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMatrixWithAllocationPriceTest.cs @@ -52,6 +52,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -98,6 +99,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -117,6 +119,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -172,6 +175,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -229,6 +233,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -282,6 +287,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -304,6 +310,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -359,6 +366,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -406,6 +414,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -461,6 +471,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -487,6 +498,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -521,6 +534,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -572,6 +586,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanMatrixWithDisplayNamePriceTest.cs b/src/Orb.Tests/Models/NewPlanMatrixWithDisplayNamePriceTest.cs index 3c47204c6..1bf83a26e 100644 --- a/src/Orb.Tests/Models/NewPlanMatrixWithDisplayNamePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMatrixWithDisplayNamePriceTest.cs @@ -58,6 +58,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -111,6 +112,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -130,6 +132,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -191,6 +194,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -254,6 +258,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -314,6 +319,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -336,6 +342,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -397,6 +404,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -450,6 +458,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -517,6 +527,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -543,6 +554,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -583,6 +596,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -640,6 +654,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanMaxGroupTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewPlanMaxGroupTieredPackagePriceTest.cs index 074719e74..2cebc52be 100644 --- a/src/Orb.Tests/Models/NewPlanMaxGroupTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMaxGroupTieredPackagePriceTest.cs @@ -55,6 +55,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -105,6 +106,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -124,6 +126,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -182,6 +185,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -242,6 +246,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -299,6 +304,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -321,6 +327,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -379,6 +386,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -429,6 +437,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -490,6 +500,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -516,6 +527,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -553,6 +566,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -607,6 +621,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanMinimumCompositePriceTest.cs b/src/Orb.Tests/Models/NewPlanMinimumCompositePriceTest.cs index 497d9abf8..b817e8430 100644 --- a/src/Orb.Tests/Models/NewPlanMinimumCompositePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanMinimumCompositePriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -90,6 +91,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -109,6 +111,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -158,6 +161,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -209,6 +213,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -260,6 +265,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -282,6 +288,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -331,6 +338,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -372,6 +380,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -415,6 +425,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -441,6 +452,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -469,6 +482,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -514,6 +528,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanPackagePriceTest.cs b/src/Orb.Tests/Models/NewPlanPackagePriceTest.cs index e7fce6e94..b66d1401c 100644 --- a/src/Orb.Tests/Models/NewPlanPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanPackagePriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -90,6 +91,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -109,6 +111,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -158,6 +161,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -209,6 +213,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -260,6 +265,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -282,6 +288,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -331,6 +338,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -372,6 +380,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -415,6 +425,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -441,6 +452,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -469,6 +482,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -514,6 +528,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanPackageWithAllocationPriceTest.cs b/src/Orb.Tests/Models/NewPlanPackageWithAllocationPriceTest.cs index ac93d3f79..d61099662 100644 --- a/src/Orb.Tests/Models/NewPlanPackageWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanPackageWithAllocationPriceTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -97,6 +98,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -116,6 +118,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -170,6 +173,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -226,6 +230,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -279,6 +284,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -301,6 +307,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -355,6 +362,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -401,6 +409,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -454,6 +464,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -480,6 +491,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -513,6 +526,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -563,6 +577,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanScalableMatrixWithTieredPricingPriceTest.cs b/src/Orb.Tests/Models/NewPlanScalableMatrixWithTieredPricingPriceTest.cs index d7b8be3f5..ae4154d4a 100644 --- a/src/Orb.Tests/Models/NewPlanScalableMatrixWithTieredPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanScalableMatrixWithTieredPricingPriceTest.cs @@ -65,6 +65,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -124,6 +125,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -146,6 +148,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -214,6 +217,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -284,6 +288,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -350,6 +355,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -375,6 +381,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -443,6 +450,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -503,6 +511,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -584,6 +594,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -610,6 +621,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -657,6 +670,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -721,6 +735,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs index fc91d28d4..d19fd1672 100644 --- a/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs @@ -62,6 +62,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -118,6 +119,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -140,6 +142,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -205,6 +208,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -272,6 +276,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -335,6 +340,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -360,6 +366,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -425,6 +432,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -482,6 +490,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -557,6 +567,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -583,6 +594,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -627,6 +640,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -688,6 +702,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanThresholdTotalAmountPriceTest.cs b/src/Orb.Tests/Models/NewPlanThresholdTotalAmountPriceTest.cs index 9f7918c9f..519e329cf 100644 --- a/src/Orb.Tests/Models/NewPlanThresholdTotalAmountPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanThresholdTotalAmountPriceTest.cs @@ -54,6 +54,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -103,6 +104,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -122,6 +124,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -179,6 +182,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -238,6 +242,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -294,6 +299,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -316,6 +322,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -373,6 +380,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -422,6 +430,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -481,6 +491,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -507,6 +518,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -543,6 +556,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -596,6 +610,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanTieredPackagePriceTest.cs b/src/Orb.Tests/Models/NewPlanTieredPackagePriceTest.cs index dab3533ad..37a671037 100644 --- a/src/Orb.Tests/Models/NewPlanTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanTieredPackagePriceTest.cs @@ -54,6 +54,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -102,6 +103,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -121,6 +123,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -178,6 +181,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -237,6 +241,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -292,6 +297,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -314,6 +320,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -371,6 +378,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -420,6 +428,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -479,6 +489,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -505,6 +516,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -541,6 +554,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -594,6 +608,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanTieredPackageWithMinimumPriceTest.cs b/src/Orb.Tests/Models/NewPlanTieredPackageWithMinimumPriceTest.cs index 19e8a8887..1d6193a47 100644 --- a/src/Orb.Tests/Models/NewPlanTieredPackageWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanTieredPackageWithMinimumPriceTest.cs @@ -64,6 +64,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -123,6 +124,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -142,6 +144,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -209,6 +212,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -278,6 +282,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -344,6 +349,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -369,6 +375,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -436,6 +443,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -495,6 +503,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -574,6 +584,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -600,6 +611,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -646,6 +659,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -709,6 +723,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanTieredPriceTest.cs b/src/Orb.Tests/Models/NewPlanTieredPriceTest.cs index bfd258249..fffad40db 100644 --- a/src/Orb.Tests/Models/NewPlanTieredPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanTieredPriceTest.cs @@ -58,6 +58,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -110,6 +111,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -129,6 +131,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -190,6 +193,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -253,6 +257,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -312,6 +317,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -334,6 +340,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -395,6 +402,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -448,6 +456,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -515,6 +525,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -541,6 +552,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -581,6 +594,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -638,6 +652,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanTieredWithMinimumPriceTest.cs b/src/Orb.Tests/Models/NewPlanTieredWithMinimumPriceTest.cs index 337458ae7..954a859db 100644 --- a/src/Orb.Tests/Models/NewPlanTieredWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanTieredWithMinimumPriceTest.cs @@ -65,6 +65,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -124,6 +125,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -143,6 +145,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -211,6 +214,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -281,6 +285,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -347,6 +352,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -369,6 +375,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -437,6 +444,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -497,6 +505,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -578,6 +588,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -604,6 +615,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -651,6 +664,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -715,6 +729,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanUnitPriceTest.cs b/src/Orb.Tests/Models/NewPlanUnitPriceTest.cs index 6b0ccfd11..620f10166 100644 --- a/src/Orb.Tests/Models/NewPlanUnitPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanUnitPriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -85,6 +86,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -104,6 +106,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -153,6 +156,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -204,6 +208,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -250,6 +255,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -272,6 +278,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -321,6 +328,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -362,6 +370,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -405,6 +415,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -431,6 +442,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -459,6 +472,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -504,6 +518,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanUnitWithPercentPriceTest.cs b/src/Orb.Tests/Models/NewPlanUnitWithPercentPriceTest.cs index 506526242..12569f1fa 100644 --- a/src/Orb.Tests/Models/NewPlanUnitWithPercentPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanUnitWithPercentPriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -90,6 +91,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -109,6 +111,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -158,6 +161,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -209,6 +213,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -260,6 +265,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -282,6 +288,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -331,6 +338,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -372,6 +380,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -415,6 +425,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -441,6 +452,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -469,6 +482,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -514,6 +528,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/NewPlanUnitWithProrationPriceTest.cs b/src/Orb.Tests/Models/NewPlanUnitWithProrationPriceTest.cs index afbd17608..bc9057ee7 100644 --- a/src/Orb.Tests/Models/NewPlanUnitWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanUnitWithProrationPriceTest.cs @@ -46,6 +46,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -88,6 +89,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -107,6 +109,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -156,6 +159,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -207,6 +211,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -256,6 +261,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -278,6 +284,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -327,6 +334,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -368,6 +376,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -411,6 +421,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -437,6 +448,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -465,6 +478,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -510,6 +524,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/PerPriceCostTest.cs b/src/Orb.Tests/Models/PerPriceCostTest.cs index aaa74e604..bdc38ce32 100644 --- a/src/Orb.Tests/Models/PerPriceCostTest.cs +++ b/src/Orb.Tests/Models/PerPriceCostTest.cs @@ -54,6 +54,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -121,6 +122,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -169,6 +176,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -232,6 +240,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedPriceID = "price_id"; string expectedSubtotal = "subtotal"; @@ -291,6 +305,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -358,6 +373,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -420,6 +441,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -487,6 +509,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -542,6 +570,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -605,6 +634,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedPriceID = "price_id"; string expectedSubtotal = "subtotal"; @@ -664,6 +699,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -731,6 +767,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -787,6 +829,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -854,6 +897,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -910,6 +959,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -977,6 +1027,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -1032,6 +1088,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1099,6 +1156,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -1157,6 +1220,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1224,6 +1288,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -1281,6 +1351,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1348,6 +1419,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", diff --git a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs index a8080c27a..76efdc31c 100644 --- a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs @@ -42,6 +42,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -81,6 +82,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -158,6 +160,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -197,6 +200,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -310,6 +314,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -349,6 +354,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -434,6 +440,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -473,6 +480,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -561,6 +569,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -600,6 +609,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -654,6 +664,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -693,6 +704,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -754,6 +766,7 @@ public void Url_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -793,6 +806,7 @@ public void Url_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -837,6 +851,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -876,6 +891,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -960,6 +976,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -999,6 +1016,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1025,6 +1043,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -1063,6 +1082,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1098,6 +1118,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1137,6 +1158,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1174,6 +1196,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1213,6 +1236,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1243,6 +1267,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; long expectedPlanPhaseOrder = 0; @@ -1281,6 +1306,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1316,6 +1342,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1355,6 +1382,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1441,6 +1469,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -1480,6 +1509,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1531,6 +1561,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1587,6 +1618,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1631,6 +1663,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1682,6 +1715,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1726,6 +1760,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1775,6 +1810,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1827,6 +1863,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1879,6 +1916,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1942,6 +1980,7 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1994,6 +2033,7 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2057,6 +2097,7 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2106,6 +2147,7 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2150,6 +2192,7 @@ public void NewPlanUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2200,6 +2243,7 @@ public void NewPlanMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2245,6 +2289,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2289,6 +2334,7 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2338,6 +2384,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2387,6 +2434,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2437,6 +2485,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2496,6 +2545,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2545,6 +2595,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2601,6 +2652,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2654,6 +2706,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2707,6 +2760,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2767,6 +2821,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2830,6 +2885,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2886,6 +2942,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2935,6 +2992,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2979,6 +3037,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3022,6 +3081,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3070,6 +3130,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3114,6 +3175,7 @@ public void NewPlanUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3176,6 +3238,7 @@ public void NewPlanTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3226,6 +3289,7 @@ public void NewPlanBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3283,6 +3347,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3333,6 +3398,7 @@ public void NewPlanPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3388,6 +3454,7 @@ public void NewPlanMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3446,6 +3513,7 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3504,6 +3572,7 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3573,6 +3642,7 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3631,6 +3701,7 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3700,6 +3771,7 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3755,6 +3827,7 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3805,6 +3878,7 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3861,6 +3935,7 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3912,6 +3987,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3962,6 +4038,7 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4017,6 +4094,7 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4072,6 +4150,7 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4128,6 +4207,7 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4193,6 +4273,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4248,6 +4329,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4310,6 +4392,7 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4369,6 +4452,7 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4428,6 +4512,7 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4494,6 +4579,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4563,6 +4649,7 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4625,6 +4712,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4680,6 +4768,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4730,6 +4819,7 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4779,6 +4869,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4833,6 +4924,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4893,6 +4985,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4939,6 +5032,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -4958,6 +5052,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5014,6 +5109,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5072,6 +5168,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5125,6 +5222,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -5147,6 +5245,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5203,6 +5302,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5251,6 +5351,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -5308,6 +5410,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5334,6 +5437,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -5369,6 +5474,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5421,6 +5527,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5909,6 +6016,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5950,6 +6058,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -5969,6 +6078,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6019,6 +6129,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6071,6 +6182,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6119,6 +6231,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6141,6 +6254,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6191,6 +6305,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6233,6 +6348,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6278,6 +6395,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6304,6 +6422,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6333,6 +6453,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6379,6 +6500,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6756,6 +6878,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6803,6 +6926,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6825,6 +6949,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6879,6 +7004,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6935,6 +7061,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6989,6 +7116,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7014,6 +7142,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7068,6 +7197,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7114,6 +7244,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7167,6 +7299,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7193,6 +7326,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7226,6 +7361,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7276,6 +7412,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7582,6 +7719,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7629,6 +7767,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7651,6 +7790,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7705,6 +7845,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7761,6 +7902,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7815,6 +7957,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7840,6 +7983,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7894,6 +8038,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7940,6 +8085,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7993,6 +8140,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8019,6 +8167,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8052,6 +8202,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8102,6 +8253,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8402,6 +8554,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8440,6 +8593,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8459,6 +8613,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8507,6 +8662,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8554,6 +8710,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8599,6 +8756,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8621,6 +8779,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8669,6 +8828,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8709,6 +8869,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8750,6 +8912,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8776,6 +8939,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8803,6 +8968,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8847,6 +9013,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9106,6 +9273,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9149,6 +9317,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9168,6 +9337,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -9221,6 +9391,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9276,6 +9447,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9326,6 +9498,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9348,6 +9521,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9401,6 +9575,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9446,6 +9621,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9497,6 +9674,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9523,6 +9701,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9555,6 +9735,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9604,6 +9785,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs b/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs index 07d8d076b..fefc07a81 100644 --- a/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs @@ -214,6 +214,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -282,6 +283,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -496,6 +503,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -563,6 +571,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -795,6 +809,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -863,6 +878,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1093,6 +1114,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1161,6 +1183,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1382,6 +1410,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1449,6 +1478,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1681,6 +1716,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1749,6 +1785,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1973,6 +2015,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2041,6 +2084,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() diff --git a/src/Orb.Tests/Models/Plans/PlanTest.cs b/src/Orb.Tests/Models/Plans/PlanTest.cs index 39e202821..3cb4037e6 100644 --- a/src/Orb.Tests/Models/Plans/PlanTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanTest.cs @@ -209,6 +209,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -276,6 +277,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -482,6 +489,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -549,6 +557,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ]; Product expectedProduct = new() @@ -809,6 +823,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -876,6 +891,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1094,6 +1115,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1161,6 +1183,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1371,6 +1399,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1438,6 +1467,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ]; Product expectedProduct = new() @@ -1698,6 +1733,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1765,6 +1801,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1980,6 +2022,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2047,6 +2090,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() diff --git a/src/Orb.Tests/Models/PriceIntervalTest.cs b/src/Orb.Tests/Models/PriceIntervalTest.cs index 7098fcce2..dc848edd7 100644 --- a/src/Orb.Tests/Models/PriceIntervalTest.cs +++ b/src/Orb.Tests/Models/PriceIntervalTest.cs @@ -70,6 +70,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -137,6 +138,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -203,6 +210,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -266,6 +274,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); List expectedUsageCustomerIds = ["string"]; @@ -361,6 +375,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -428,6 +443,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -504,6 +525,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -571,6 +593,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -644,6 +672,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -707,6 +736,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); List expectedUsageCustomerIds = ["string"]; @@ -805,6 +840,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -872,6 +908,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -942,6 +984,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1009,6 +1052,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], diff --git a/src/Orb.Tests/Models/PriceTest.cs b/src/Orb.Tests/Models/PriceTest.cs index 9e2720f78..17f17612a 100644 --- a/src/Orb.Tests/Models/PriceTest.cs +++ b/src/Orb.Tests/Models/PriceTest.cs @@ -53,6 +53,7 @@ public void UnitValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -116,6 +117,12 @@ public void UnitValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -164,6 +171,7 @@ public void TieredValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -239,6 +247,12 @@ public void TieredValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -288,6 +302,7 @@ public void BulkValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -350,6 +365,12 @@ public void BulkValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -407,6 +428,7 @@ public void BulkWithFiltersValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -469,6 +491,12 @@ public void BulkWithFiltersValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -517,6 +545,7 @@ public void PackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -580,6 +609,12 @@ public void PackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -628,6 +663,7 @@ public void MatrixValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -696,6 +732,12 @@ public void MatrixValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -744,6 +786,7 @@ public void ThresholdTotalAmountValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -815,6 +858,12 @@ public void ThresholdTotalAmountValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -863,6 +912,7 @@ public void TieredPackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -934,6 +984,12 @@ public void TieredPackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -982,6 +1038,7 @@ public void TieredWithMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1064,6 +1121,12 @@ public void TieredWithMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1112,6 +1175,7 @@ public void GroupedTieredValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1183,6 +1247,12 @@ public void GroupedTieredValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1231,6 +1301,7 @@ public void TieredPackageWithMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1312,6 +1383,12 @@ public void TieredPackageWithMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1360,6 +1437,7 @@ public void PackageWithAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1428,6 +1506,12 @@ public void PackageWithAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1476,6 +1560,7 @@ public void UnitWithPercentValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1539,6 +1624,12 @@ public void UnitWithPercentValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1587,6 +1678,7 @@ public void MatrixWithAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1656,6 +1748,12 @@ public void MatrixWithAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1704,6 +1802,7 @@ public void TieredWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1769,6 +1868,12 @@ public void TieredWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1817,6 +1922,7 @@ public void UnitWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1880,6 +1986,12 @@ public void UnitWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1928,6 +2040,7 @@ public void GroupedAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1996,6 +2109,12 @@ public void GroupedAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2050,6 +2169,7 @@ public void BulkWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2112,6 +2232,12 @@ public void BulkWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2160,6 +2286,7 @@ public void GroupedWithProratedMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2228,6 +2355,12 @@ public void GroupedWithProratedMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2276,6 +2409,7 @@ public void GroupedWithMeteredMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2353,6 +2487,12 @@ public void GroupedWithMeteredMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2401,6 +2541,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2470,6 +2611,12 @@ public void GroupedWithMinMaxThresholdsValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2518,6 +2665,7 @@ public void MatrixWithDisplayNameValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2593,6 +2741,12 @@ public void MatrixWithDisplayNameValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2641,6 +2795,7 @@ public void GroupedTieredPackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2713,6 +2868,12 @@ public void GroupedTieredPackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2761,6 +2922,7 @@ public void MaxGroupTieredPackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2833,6 +2995,12 @@ public void MaxGroupTieredPackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2881,6 +3049,7 @@ public void ScalableMatrixWithUnitPricingValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2959,6 +3128,12 @@ public void ScalableMatrixWithUnitPricingValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3007,6 +3182,7 @@ public void ScalableMatrixWithTieredPricingValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3088,6 +3264,12 @@ public void ScalableMatrixWithTieredPricingValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3136,6 +3318,7 @@ public void CumulativeGroupedBulkValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -3211,6 +3394,12 @@ public void CumulativeGroupedBulkValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3259,6 +3448,7 @@ public void CumulativeGroupedAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -3328,6 +3518,12 @@ public void CumulativeGroupedAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3376,6 +3572,7 @@ public void MinimumCompositeValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3439,6 +3636,12 @@ public void MinimumCompositeValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3487,6 +3690,7 @@ public void PercentValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3550,6 +3754,12 @@ public void PercentValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3598,6 +3808,7 @@ public void EventOutputValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3666,6 +3877,12 @@ public void EventOutputValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3714,6 +3931,7 @@ public void UnitSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3777,6 +3995,12 @@ public void UnitSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -3828,6 +4052,7 @@ public void TieredSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3903,6 +4128,12 @@ public void TieredSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -3955,6 +4186,7 @@ public void BulkSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4017,6 +4249,12 @@ public void BulkSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -4077,6 +4315,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4139,6 +4378,12 @@ public void BulkWithFiltersSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -4190,6 +4435,7 @@ public void PackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4253,6 +4499,12 @@ public void PackageSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -4304,6 +4556,7 @@ public void MatrixSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4372,6 +4625,12 @@ public void MatrixSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -4423,6 +4682,7 @@ public void ThresholdTotalAmountSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4494,6 +4754,12 @@ public void ThresholdTotalAmountSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -4545,6 +4811,7 @@ public void TieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4616,6 +4883,12 @@ public void TieredPackageSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -4667,6 +4940,7 @@ public void TieredWithMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4749,6 +5023,12 @@ public void TieredWithMinimumSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -4800,6 +5080,7 @@ public void GroupedTieredSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4871,6 +5152,12 @@ public void GroupedTieredSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -4922,6 +5209,7 @@ public void TieredPackageWithMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5003,6 +5291,12 @@ public void TieredPackageWithMinimumSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5054,6 +5348,7 @@ public void PackageWithAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5122,6 +5417,12 @@ public void PackageWithAllocationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5173,6 +5474,7 @@ public void UnitWithPercentSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5236,6 +5538,12 @@ public void UnitWithPercentSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5287,6 +5595,7 @@ public void MatrixWithAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5356,6 +5665,12 @@ public void MatrixWithAllocationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5407,6 +5722,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5472,6 +5788,12 @@ public void TieredWithProrationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5523,6 +5845,7 @@ public void UnitWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5586,6 +5909,12 @@ public void UnitWithProrationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5637,6 +5966,7 @@ public void GroupedAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5705,6 +6035,12 @@ public void GroupedAllocationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5762,6 +6098,7 @@ public void BulkWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5824,6 +6161,12 @@ public void BulkWithProrationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5875,6 +6218,7 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5943,6 +6287,12 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5994,6 +6344,7 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6071,6 +6422,12 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6122,6 +6479,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6191,6 +6549,12 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6242,6 +6606,7 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6317,6 +6682,12 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6368,6 +6739,7 @@ public void GroupedTieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6440,6 +6812,12 @@ public void GroupedTieredPackageSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6491,6 +6869,7 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6563,6 +6942,12 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6614,6 +6999,7 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6692,6 +7078,12 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6743,6 +7135,7 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6824,6 +7217,12 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6875,6 +7274,7 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -6950,6 +7350,12 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7001,6 +7407,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -7070,6 +7477,12 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7121,6 +7534,7 @@ public void MinimumCompositeSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7184,6 +7598,12 @@ public void MinimumCompositeSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7235,6 +7655,7 @@ public void PercentSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7298,6 +7719,12 @@ public void PercentSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7349,6 +7776,7 @@ public void EventOutputSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7417,6 +7845,12 @@ public void EventOutputSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7471,6 +7905,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7534,6 +7969,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -7579,6 +8020,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -7647,6 +8089,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + LicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -7687,6 +8135,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedUnitConfig, model.UnitConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -7733,6 +8182,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7796,6 +8246,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -7848,6 +8304,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7911,6 +8368,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -7960,6 +8423,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -8028,6 +8492,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + LicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -8071,6 +8541,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -8117,6 +8588,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8180,6 +8652,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -8229,6 +8707,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8291,6 +8770,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -8337,6 +8818,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8444,6 +8926,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8504,10 +8987,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -8554,6 +9040,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8614,6 +9101,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -8663,6 +9151,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8726,6 +9215,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; Unit copied = new(model); @@ -9222,6 +9717,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class LicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 LicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + LicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class TieredTest : TestBase { [Fact] @@ -9268,6 +9858,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9343,6 +9934,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -9389,6 +9986,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -9469,6 +10067,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -9509,6 +10113,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedTieredConfig, model.TieredConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -9555,6 +10160,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9630,6 +10236,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -9682,6 +10294,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9757,6 +10370,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -9807,6 +10426,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -9887,6 +10507,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -9930,6 +10556,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -9976,6 +10603,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10051,244 +10679,11 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Tiered - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredBillingMode.InAdvance, - Cadence = TieredCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = TieredCompositePriceFilterField.PriceID, - Operator = TieredCompositePriceFilterOperator.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() + LicenseType = new() { - 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 = TieredPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Tiered - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredBillingMode.InAdvance, - Cadence = TieredCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = TieredCompositePriceFilterField.PriceID, - Operator = TieredCompositePriceFilterOperator.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 = TieredPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, }; @@ -10296,7 +10691,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new Tiered { @@ -10339,6 +10734,250 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + 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 = TieredPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + }; + + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Tiered + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredBillingMode.InAdvance, + Cadence = TieredCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredCompositePriceFilterField.PriceID, + Operator = TieredCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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 = TieredPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Tiered + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredBillingMode.InAdvance, + Cadence = TieredCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredCompositePriceFilterField.PriceID, + Operator = TieredCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10411,10 +11050,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -10461,6 +11103,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10533,6 +11176,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -10582,6 +11226,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10657,6 +11302,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; Tiered copied = new(model); @@ -11151,6 +11802,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class TieredLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 TieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + TieredLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class BulkTest : TestBase { [Fact] @@ -11198,6 +11944,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11260,6 +12007,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -11308,6 +12061,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -11375,6 +12129,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + BulkLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -11415,6 +12175,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -11462,6 +12223,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11524,6 +12286,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -11577,6 +12345,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11639,6 +12408,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -11691,6 +12466,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -11758,6 +12534,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + BulkLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -11801,6 +12583,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -11848,6 +12631,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11910,6 +12694,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -11960,6 +12750,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12021,6 +12812,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -12068,6 +12861,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12175,6 +12969,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12234,10 +13029,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -12285,6 +13083,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12344,6 +13143,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -12394,6 +13194,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12456,6 +13257,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; Bulk copied = new(model); @@ -12950,6 +13757,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class BulkLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 BulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + BulkLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class BulkWithFiltersTest : TestBase { [Fact] @@ -13005,6 +13907,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13067,6 +13970,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -13123,6 +14032,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -13191,6 +14101,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + BulkWithFiltersLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -13231,6 +14147,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -13286,6 +14203,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13348,6 +14266,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -13412,6 +14336,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13474,6 +14399,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -13537,6 +14468,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -13605,6 +14537,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + BulkWithFiltersLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -13648,6 +14586,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -13703,6 +14642,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13765,6 +14705,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -13823,6 +14769,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13884,6 +14831,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -13939,6 +14888,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14054,6 +15004,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14113,10 +15064,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -14172,6 +15126,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14231,6 +15186,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -14289,6 +15245,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14351,6 +15308,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; BulkWithFilters copied = new(model); @@ -15173,6 +16136,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class BulkWithFiltersLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithFiltersLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithFiltersLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 BulkWithFiltersLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithFiltersLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + BulkWithFiltersLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class PackageTest : TestBase { [Fact] @@ -15219,6 +16277,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15282,6 +16341,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -15328,6 +16393,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -15400,6 +16466,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + PackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -15440,6 +16512,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -15486,6 +16559,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15549,6 +16623,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -15601,6 +16681,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15664,6 +16745,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -15717,6 +16804,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -15789,6 +16877,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + PackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -15832,6 +16926,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -15878,6 +16973,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15941,6 +17037,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -15990,6 +17092,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16052,6 +17155,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -16098,6 +17203,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16205,6 +17311,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16265,10 +17372,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -16315,6 +17425,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16375,6 +17486,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -16424,6 +17536,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16487,6 +17600,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; Package copied = new(model); @@ -16979,6 +18098,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class PackageLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 PackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + PackageLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class MatrixTest : TestBase { [Fact] @@ -17025,6 +18239,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17093,6 +18308,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -17139,6 +18360,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -17212,6 +18434,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -17252,6 +18480,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -17298,6 +18527,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17366,6 +18596,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -17418,6 +18654,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17486,6 +18723,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -17536,6 +18779,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -17609,6 +18853,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -17652,6 +18902,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -17698,6 +18949,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17766,6 +19018,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -17815,6 +19073,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17882,6 +19141,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -17928,6 +19189,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18040,6 +19302,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18105,10 +19368,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -18155,6 +19421,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18220,6 +19487,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -18269,6 +19537,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18337,6 +19606,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; Matrix copied = new(model); @@ -18831,6 +20106,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MatrixLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 MatrixLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MatrixLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class ThresholdTotalAmountTest : TestBase { [Fact] @@ -18877,6 +20247,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18948,6 +20319,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -18996,6 +20373,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -19073,6 +20451,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + ThresholdTotalAmountLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -19113,6 +20497,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedThresholdTotalAmountConfig, model.ThresholdTotalAmountConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -19159,6 +20544,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19230,6 +20616,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -19285,6 +20677,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19356,6 +20749,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -19411,6 +20810,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -19488,6 +20888,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + ThresholdTotalAmountLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -19531,6 +20937,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -19577,6 +20984,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19648,6 +21056,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -19697,6 +21111,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19767,6 +21182,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -19813,6 +21230,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19928,6 +21346,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19996,10 +21415,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -20046,6 +21468,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20114,6 +21537,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -20163,6 +21587,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20234,6 +21659,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; ThresholdTotalAmount copied = new(model); @@ -21000,6 +22431,101 @@ public void CopyConstructor_Works() } } +public class ThresholdTotalAmountLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdTotalAmountLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ThresholdTotalAmountLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 ThresholdTotalAmountLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new ThresholdTotalAmountLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmountLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + ThresholdTotalAmountLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class TieredPackageTest : TestBase { [Fact] @@ -21046,6 +22572,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21117,6 +22644,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -21164,6 +22697,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -21241,6 +22775,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -21281,6 +22821,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedTieredPackageConfig, model.TieredPackageConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -21327,6 +22868,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21398,6 +22940,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -21453,6 +23001,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21524,6 +23073,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -21578,6 +23133,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -21655,6 +23211,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -21698,6 +23260,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -21744,6 +23307,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21815,6 +23379,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -21864,6 +23434,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21934,6 +23505,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -21980,6 +23553,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22095,6 +23669,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22163,10 +23738,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -22213,6 +23791,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22281,6 +23860,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -22330,6 +23910,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22401,6 +23982,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; TieredPackage copied = new(model); @@ -23099,6 +24686,101 @@ public void CopyConstructor_Works() } } +public class TieredPackageLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 TieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + TieredPackageLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class TieredWithMinimumTest : TestBase { [Fact] @@ -23145,6 +24827,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23227,6 +24910,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -23275,6 +24964,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -23363,6 +25053,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredWithMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -23403,6 +25099,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedTieredWithMinimumConfig, model.TieredWithMinimumConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -23449,6 +25146,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23531,6 +25229,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -23586,6 +25290,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23668,6 +25373,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -23723,6 +25434,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -23811,6 +25523,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredWithMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -23854,6 +25572,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -23900,6 +25619,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23982,258 +25702,11 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new TieredWithMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithMinimumBillingMode.InAdvance, - Cadence = TieredWithMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = TieredWithMinimumCompositePriceFilterField.PriceID, - Operator = TieredWithMinimumCompositePriceFilterOperator.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() + LicenseType = 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 = 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, - }, - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new TieredWithMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithMinimumBillingMode.InAdvance, - Cadence = TieredWithMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = TieredWithMinimumCompositePriceFilterField.PriceID, - Operator = TieredWithMinimumCompositePriceFilterOperator.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 = 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, + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, }; @@ -24241,7 +25714,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new TieredWithMinimum { @@ -24284,6 +25757,264 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + 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 = 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, + }, + }; + + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredWithMinimumBillingMode.InAdvance, + Cadence = TieredWithMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredWithMinimumCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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 = 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, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredWithMinimumBillingMode.InAdvance, + Cadence = TieredWithMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredWithMinimumCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24363,10 +26094,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -24413,6 +26147,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24492,6 +26227,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -24541,6 +26277,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24623,6 +26360,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; TieredWithMinimum copied = new(model); @@ -25521,6 +27264,101 @@ public void CopyConstructor_Works() } } +public class TieredWithMinimumLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 TieredWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + TieredWithMinimumLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedTieredTest : TestBase { [Fact] @@ -25567,6 +27405,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25638,6 +27477,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -25685,6 +27530,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -25762,6 +27608,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedTieredLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -25802,6 +27654,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -25848,6 +27701,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25919,6 +27773,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -25974,6 +27834,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26045,6 +27906,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -26099,6 +27966,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -26176,6 +28044,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedTieredLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -26219,6 +28093,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -26265,6 +28140,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26336,6 +28212,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -26385,6 +28267,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26455,6 +28338,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -26501,6 +28386,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26616,6 +28502,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26684,10 +28571,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -26734,6 +28624,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26802,6 +28693,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -26851,6 +28743,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26922,6 +28815,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; GroupedTiered copied = new(model); @@ -27620,6 +29519,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedTieredLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 GroupedTieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedTieredLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class TieredPackageWithMinimumTest : TestBase { [Fact] @@ -27666,6 +29660,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27747,6 +29742,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -27795,6 +29796,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -27885,6 +29887,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredPackageWithMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -27925,6 +29933,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedTieredPackageWithMinimumConfig, model.TieredPackageWithMinimumConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -27971,6 +29980,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28052,6 +30062,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -28107,6 +30123,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28188,6 +30205,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -28243,6 +30266,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -28333,6 +30357,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredPackageWithMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -28379,6 +30409,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -28425,6 +30456,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28506,6 +30538,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -28555,6 +30593,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28635,6 +30674,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -28681,6 +30722,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28806,6 +30848,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28884,10 +30927,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -28934,6 +30980,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29012,6 +31059,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -29061,6 +31109,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29142,6 +31191,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; TieredPackageWithMinimum copied = new(model); @@ -29919,6 +31974,101 @@ public void CopyConstructor_Works() } } +public class TieredPackageWithMinimumLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 TieredPackageWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + TieredPackageWithMinimumLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class PackageWithAllocationTest : TestBase { [Fact] @@ -29965,6 +32115,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30033,6 +32184,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -30081,6 +32238,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -30157,6 +32315,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + PackageWithAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -30197,6 +32361,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -30243,6 +32408,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30311,6 +32477,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -30366,6 +32538,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30434,6 +32607,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -30489,6 +32668,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -30565,6 +32745,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + PackageWithAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -30608,6 +32794,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -30654,6 +32841,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30722,6 +32910,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -30771,6 +32965,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30838,6 +33033,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -30884,6 +33081,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30996,6 +33194,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31061,10 +33260,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -31111,6 +33313,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31176,6 +33379,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -31225,6 +33429,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31293,6 +33498,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; PackageWithAllocation copied = new(model); @@ -31878,6 +34089,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class PackageWithAllocationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 PackageWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + PackageWithAllocationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class UnitWithPercentTest : TestBase { [Fact] @@ -31924,6 +34230,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31987,6 +34294,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -32034,6 +34347,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -32107,6 +34421,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + UnitWithPercentLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -32147,6 +34467,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedUnitWithPercentConfig, model.UnitWithPercentConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -32193,6 +34514,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32256,6 +34578,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -32311,6 +34639,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32374,6 +34703,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -32428,6 +34763,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -32501,6 +34837,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + UnitWithPercentLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -32544,6 +34886,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -32590,6 +34933,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32653,6 +34997,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -32702,6 +35052,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32764,6 +35115,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -32810,6 +35163,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32917,6 +35271,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32977,10 +35332,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -33027,6 +35385,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33087,6 +35446,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -33136,6 +35496,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33199,6 +35560,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; UnitWithPercent copied = new(model); @@ -33775,6 +36142,101 @@ public void CopyConstructor_Works() } } +public class UnitWithPercentLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithPercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 UnitWithPercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithPercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + UnitWithPercentLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class MatrixWithAllocationTest : TestBase { [Fact] @@ -33821,6 +36283,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33890,6 +36353,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -33938,6 +36407,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -34013,6 +36483,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixWithAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -34053,6 +36529,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -34099,6 +36576,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34168,6 +36646,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -34223,6 +36707,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34292,6 +36777,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -34347,6 +36838,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -34422,6 +36914,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixWithAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -34465,6 +36963,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -34511,6 +37010,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34580,6 +37080,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -34629,6 +37135,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34697,6 +37204,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -34743,6 +37252,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34856,6 +37366,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34922,10 +37433,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -34972,6 +37486,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -35038,6 +37553,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -35087,6 +37603,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -35156,6 +37673,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; MatrixWithAllocation copied = new(model); @@ -35644,6 +38167,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MatrixWithAllocationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MatrixWithAllocationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class TieredWithProrationTest : TestBase { [Fact] @@ -35690,6 +38308,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -35755,6 +38374,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -35803,6 +38428,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -35874,6 +38500,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -35914,6 +38546,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -35960,6 +38593,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36025,6 +38659,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -36080,6 +38720,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36145,6 +38786,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -36200,6 +38847,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -36271,6 +38919,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -36314,6 +38968,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -36360,6 +39015,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36425,6 +39081,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -36474,6 +39136,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36538,6 +39201,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -36584,6 +39249,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36693,6 +39359,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36755,10 +39422,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ), DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -36805,6 +39475,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36867,6 +39538,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ), DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -36916,6 +39588,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36981,6 +39654,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; TieredWithProration copied = new(model); @@ -37648,6 +40327,101 @@ public void CopyConstructor_Works() } } +public class TieredWithProrationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + TieredWithProrationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class UnitWithProrationTest : TestBase { [Fact] @@ -37694,6 +40468,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37757,6 +40532,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -37805,6 +40586,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -37876,6 +40658,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + UnitWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -37916,6 +40704,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -37962,6 +40751,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38025,6 +40815,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -38080,6 +40876,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38143,6 +40940,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -38198,6 +41001,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -38269,6 +41073,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + UnitWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -38312,6 +41122,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -38358,6 +41169,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38421,6 +41233,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -38470,6 +41288,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38532,6 +41351,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -38578,6 +41399,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38685,6 +41507,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38745,10 +41568,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() UnitWithProrationConfig = new("unit_amount"), DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -38795,6 +41621,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38855,6 +41682,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UnitWithProrationConfig = new("unit_amount"), DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -38904,6 +41732,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38967,6 +41796,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; UnitWithProration copied = new(model); @@ -39517,6 +42352,101 @@ public void CopyConstructor_Works() } } +public class UnitWithProrationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + UnitWithProrationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedAllocationTest : TestBase { [Fact] @@ -39563,6 +42493,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39631,6 +42562,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -39679,6 +42616,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -39753,6 +42691,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -39793,6 +42737,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -39839,6 +42784,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39907,6 +42853,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -39962,6 +42914,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40030,6 +42983,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -40085,6 +43044,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -40159,6 +43119,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -40202,6 +43168,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -40248,6 +43215,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40316,6 +43284,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -40365,6 +43339,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40432,6 +43407,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -40478,6 +43455,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40590,6 +43568,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40655,10 +43634,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -40705,6 +43687,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40770,6 +43753,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -40819,6 +43803,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40887,6 +43872,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; GroupedAllocation copied = new(model); @@ -41470,6 +44461,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedAllocationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedAllocationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class BulkWithProrationTest : TestBase { [Fact] @@ -41522,6 +44608,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41584,6 +44671,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -41638,6 +44731,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -41706,6 +44800,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + BulkWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -41746,6 +44846,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -41798,6 +44899,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41860,6 +44962,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -41921,6 +45029,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41983,6 +45092,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -42044,6 +45159,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -42112,6 +45228,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + BulkWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -42155,6 +45277,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -42207,6 +45330,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42269,6 +45393,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -42324,6 +45454,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42385,6 +45516,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -42437,6 +45570,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42549,6 +45683,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42608,10 +45743,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -42664,6 +45802,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42723,6 +45862,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -42778,6 +45918,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42840,6 +45981,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; BulkWithProration copied = new(model); @@ -43571,6 +46718,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class BulkWithProrationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + BulkWithProrationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedWithProratedMinimumTest : TestBase { [Fact] @@ -43617,6 +46859,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43685,6 +46928,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -43733,6 +46982,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -43810,6 +47060,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithProratedMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -43853,6 +47109,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -43899,6 +47156,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43967,6 +47225,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -44022,6 +47286,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44090,6 +47355,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -44145,6 +47416,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -44222,6 +47494,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithProratedMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -44268,6 +47546,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -44314,6 +47593,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44382,6 +47662,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -44431,6 +47717,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44498,6 +47785,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -44544,6 +47833,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44656,6 +47946,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44721,10 +48012,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -44771,6 +48065,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44836,6 +48131,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -44885,6 +48181,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44953,6 +48250,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; GroupedWithProratedMinimum copied = new(model); @@ -45540,6 +48843,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedWithProratedMinimumLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedWithProratedMinimumLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedWithMeteredMinimumTest : TestBase { [Fact] @@ -45586,6 +48984,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45663,6 +49062,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -45711,6 +49116,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -45797,6 +49203,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithMeteredMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -45840,6 +49252,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -45886,6 +49299,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45963,6 +49377,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -46018,6 +49438,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46095,6 +49516,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -46150,6 +49577,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -46236,6 +49664,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithMeteredMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -46282,6 +49716,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -46328,6 +49763,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46405,6 +49841,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -46454,6 +49896,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46530,6 +49973,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -46576,6 +50021,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46697,6 +50143,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46771,10 +50218,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -46821,6 +50271,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46895,6 +50346,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -46944,6 +50396,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47021,6 +50474,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; GroupedWithMeteredMinimum copied = new(model); @@ -47854,6 +51313,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedWithMeteredMinimumLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedWithMeteredMinimumLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedWithMinMaxThresholdsTest : TestBase { [Fact] @@ -47900,6 +51454,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47969,6 +51524,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -48017,6 +51578,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -48094,6 +51656,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithMinMaxThresholdsLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -48137,6 +51705,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -48183,6 +51752,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48252,6 +51822,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -48307,6 +51883,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48376,6 +51953,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -48431,6 +52014,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -48508,6 +52092,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithMinMaxThresholdsLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -48554,6 +52144,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -48600,6 +52191,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48669,6 +52261,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -48718,6 +52316,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48786,6 +52385,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -48832,6 +52433,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48945,6 +52547,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49011,10 +52614,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -49061,6 +52667,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49127,6 +52734,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -49176,6 +52784,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49245,6 +52854,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; GroupedWithMinMaxThresholds copied = new(model); @@ -49839,6 +53454,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedWithMinMaxThresholdsLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedWithMinMaxThresholdsLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class MatrixWithDisplayNameTest : TestBase { [Fact] @@ -49885,6 +53595,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49960,6 +53671,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -50008,6 +53725,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -50091,6 +53809,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixWithDisplayNameLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -50131,6 +53855,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -50177,6 +53902,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50252,6 +53978,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -50307,6 +54039,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50382,6 +54115,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -50437,6 +54176,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -50520,6 +54260,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixWithDisplayNameLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -50563,6 +54309,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -50609,6 +54356,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50684,252 +54432,19 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new MatrixWithDisplayName - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.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() + LicenseType = new() { - 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" }, - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - 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 = MatrixWithDisplayNamePriceType.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 MatrixWithDisplayName - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.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" }, - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - 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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new MatrixWithDisplayName { @@ -50972,6 +54487,250 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + 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" }, + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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 = MatrixWithDisplayNamePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + }; + + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithDisplayName + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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" }, + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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 = MatrixWithDisplayNamePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithDisplayName + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51044,10 +54803,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -51094,6 +54856,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51166,6 +54929,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -51215,6 +54979,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51290,6 +55055,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; MatrixWithDisplayName copied = new(model); @@ -52027,6 +55798,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MatrixWithDisplayNameLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MatrixWithDisplayNameLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedTieredPackageTest : TestBase { [Fact] @@ -52073,6 +55939,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52145,6 +56012,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -52193,6 +56066,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -52271,6 +56145,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedTieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -52311,6 +56191,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -52357,6 +56238,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52429,6 +56311,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -52484,6 +56372,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52556,6 +56445,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -52611,6 +56506,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -52689,6 +56585,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedTieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -52732,6 +56634,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -52778,6 +56681,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52850,6 +56754,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -52899,6 +56809,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52970,6 +56881,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -53016,6 +56929,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53132,6 +57046,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53201,10 +57116,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -53251,6 +57169,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53320,6 +57239,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -53369,6 +57289,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53441,6 +57362,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; GroupedTieredPackage copied = new(model); @@ -54150,6 +58077,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedTieredPackageLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedTieredPackageLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class MaxGroupTieredPackageTest : TestBase { [Fact] @@ -54196,6 +58218,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -54268,6 +58291,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -54316,6 +58345,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -54396,6 +58426,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MaxGroupTieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -54436,6 +58472,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -54482,6 +58519,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -54554,6 +58592,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -54609,6 +58653,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -54681,6 +58726,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -54736,6 +58787,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -54816,6 +58868,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MaxGroupTieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -54859,6 +58917,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -54905,6 +58964,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -54977,6 +59037,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -55026,6 +59092,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55097,6 +59164,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -55143,6 +59212,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55259,6 +59329,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55328,10 +59399,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -55378,6 +59452,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55447,6 +59522,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -55496,6 +59572,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55568,6 +59645,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; MaxGroupTieredPackage copied = new(model); @@ -56277,6 +60360,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MaxGroupTieredPackageLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MaxGroupTieredPackageLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class ScalableMatrixWithUnitPricingTest : TestBase { [Fact] @@ -56323,6 +60501,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56401,6 +60580,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -56449,6 +60634,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -56536,6 +60722,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + ScalableMatrixWithUnitPricingLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -56579,6 +60771,7 @@ public void FieldRoundtrip_Works() model.ScalableMatrixWithUnitPricingConfig ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -56625,6 +60818,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56703,6 +60897,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -56758,6 +60958,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56836,6 +61037,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -56891,6 +61098,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -56978,6 +61186,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + ScalableMatrixWithUnitPricingLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -57024,6 +61238,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -57070,6 +61285,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57148,6 +61364,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -57197,6 +61419,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57274,6 +61497,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -57320,6 +61545,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57442,6 +61668,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57517,10 +61744,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -57567,6 +61797,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57642,6 +61873,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -57691,6 +61923,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57769,6 +62002,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; ScalableMatrixWithUnitPricing copied = new(model); @@ -58700,6 +62939,101 @@ public void CopyConstructor_Works() } } +public class ScalableMatrixWithUnitPricingLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + ScalableMatrixWithUnitPricingLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class ScalableMatrixWithTieredPricingTest : TestBase { [Fact] @@ -58746,6 +63080,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -58827,6 +63162,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -58875,6 +63216,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -58965,6 +63307,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + ScalableMatrixWithTieredPricingLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -59008,6 +63356,7 @@ public void FieldRoundtrip_Works() model.ScalableMatrixWithTieredPricingConfig ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -59054,6 +63403,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -59135,6 +63485,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -59190,6 +63546,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -59271,6 +63628,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -59326,6 +63689,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -59416,6 +63780,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + ScalableMatrixWithTieredPricingLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -59462,6 +63832,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -59508,6 +63879,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -59589,256 +63961,11 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ScalableMatrixWithTieredPricing - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.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 = ScalableMatrixWithTieredPricingPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithTieredPricingConfig = new() + LicenseType = 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", - }, - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new ScalableMatrixWithTieredPricing - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.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 = 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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, }; @@ -59846,7 +63973,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new ScalableMatrixWithTieredPricing { @@ -59889,6 +64016,262 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + 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 = 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", + }, + }; + + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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 = 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", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -59967,10 +64350,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -60017,6 +64403,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -60095,6 +64482,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -60144,6 +64532,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -60225,6 +64614,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; ScalableMatrixWithTieredPricing copied = new(model); @@ -61287,6 +65682,101 @@ public void CopyConstructor_Works() } } +public class ScalableMatrixWithTieredPricingLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + ScalableMatrixWithTieredPricingLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class CumulativeGroupedBulkTest : TestBase { [Fact] @@ -61333,6 +65823,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -61408,6 +65899,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -61456,6 +65953,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() { @@ -61539,6 +66037,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + CumulativeGroupedBulkLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -61579,6 +66083,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -61625,6 +66130,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -61700,6 +66206,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -61755,6 +66267,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -61830,6 +66343,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -61885,6 +66404,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() { @@ -61968,6 +66488,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + CumulativeGroupedBulkLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -62011,6 +66537,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -62057,6 +66584,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -62132,252 +66660,19 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new CumulativeGroupedBulk - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.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"], - }, - ], - }, - CumulativeGroupedBulkConfig = new() + LicenseType = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, - 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 = CumulativeGroupedBulkPriceType.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 CumulativeGroupedBulk - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.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"], - }, - ], - }, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, - 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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new CumulativeGroupedBulk { @@ -62420,6 +66715,250 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + 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 = CumulativeGroupedBulkPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + }; + + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CumulativeGroupedBulk + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + 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 = CumulativeGroupedBulkPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedBulk + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -62492,10 +67031,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -62542,6 +67084,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -62614,6 +67157,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -62663,6 +67207,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -62738,6 +67283,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; CumulativeGroupedBulk copied = new(model); @@ -63475,6 +68026,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class CumulativeGroupedBulkLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + CumulativeGroupedBulkLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class CumulativeGroupedAllocationTest : TestBase { [Fact] @@ -63521,6 +68167,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -63590,6 +68237,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -63638,6 +68291,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { @@ -63715,6 +68369,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + CumulativeGroupedAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -63758,6 +68418,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -63804,6 +68465,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -63873,6 +68535,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -63928,6 +68596,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -63997,6 +68666,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -64052,6 +68727,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { @@ -64129,6 +68805,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + CumulativeGroupedAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -64175,6 +68857,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -64221,6 +68904,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -64290,6 +68974,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -64339,6 +69029,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -64407,6 +69098,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -64453,6 +69146,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -64566,6 +69260,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -64632,10 +69327,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -64682,6 +69380,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -64748,6 +69447,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -64797,6 +69497,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -64866,6 +69567,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; CumulativeGroupedAllocation copied = new(model); @@ -65460,6 +70167,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class CumulativeGroupedAllocationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + CumulativeGroupedAllocationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class MinimumCompositeTest : TestBase { [Fact] @@ -65506,6 +70308,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65569,6 +70372,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -65616,6 +70425,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -65689,6 +70499,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MinimumCompositeLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -65729,6 +70545,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -65775,6 +70592,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65838,6 +70656,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -65893,6 +70717,301 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + 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 = + MinimumCompositeBillingMode.InAdvance; + ApiEnum expectedCadence = MinimumCompositeCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = MinimumCompositeCompositePriceFilterField.PriceID, + Operator = MinimumCompositeCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + MinimumCompositeConversionRateConfig 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"], + }, + ], + LicenseTypeID = "license_type_id", + }; + 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"; + MinimumCompositeMinimumCompositeConfig expectedMinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = + MinimumCompositePriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }; + MinimumCompositeLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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(expectedMinimumCompositeConfig, deserialized.MinimumCompositeConfig); + 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 + ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); + } + + [Fact] + public void Validation_Works() + { + var model = 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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65956,284 +71075,11 @@ public void FieldRoundtripThroughSerialization_Works() 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 = - MinimumCompositeBillingMode.InAdvance; - ApiEnum expectedCadence = MinimumCompositeCadence.OneTime; - List expectedCompositePriceFilters = - [ - new() - { - Field = MinimumCompositeCompositePriceFilterField.PriceID, - Operator = MinimumCompositeCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ]; - double expectedConversionRate = 0; - MinimumCompositeConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() + LicenseType = new() { - 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"; - MinimumCompositeMinimumCompositeConfig expectedMinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); - string expectedName = "name"; - long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - MinimumCompositePriceType.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(expectedMinimumCompositeConfig, deserialized.MinimumCompositeConfig); - 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 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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, }; @@ -66284,6 +71130,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66346,6 +71193,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -66392,6 +71241,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66499,6 +71349,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66559,10 +71410,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -66609,6 +71463,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66669,6 +71524,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -66718,6 +71574,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66781,6 +71638,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; MinimumComposite copied = new(model); @@ -67403,6 +72266,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MinimumCompositeLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumCompositeLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MinimumCompositeLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 MinimumCompositeLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new MinimumCompositeLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MinimumCompositeLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class PercentTest : TestBase { [Fact] @@ -67449,6 +72407,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67512,6 +72471,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -67558,6 +72523,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -67626,6 +72592,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + PercentLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -67666,6 +72638,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -67712,6 +72685,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67775,6 +72749,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -67827,6 +72807,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67890,6 +72871,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -67943,6 +72930,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -68011,6 +72999,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + PercentLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -68054,6 +73048,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -68100,6 +73095,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -68163,6 +73159,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -68212,6 +73214,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -68274,6 +73277,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -68320,6 +73325,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -68427,6 +73433,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -68487,10 +73494,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -68537,6 +73547,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -68597,6 +73608,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -68646,6 +73658,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -68709,6 +73722,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; Percent copied = new(model); @@ -69263,6 +74282,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class PercentLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 PercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new PercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + PercentLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class EventOutputTest : TestBase { [Fact] @@ -69309,6 +74423,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -69377,6 +74492,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -69424,6 +74545,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -69497,6 +74619,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + EventOutputLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -69537,6 +74665,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -69583,6 +74712,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -69651,6 +74781,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -69706,6 +74842,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -69774,6 +74911,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -69828,6 +74971,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -69901,6 +75045,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + EventOutputLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -69944,6 +75094,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -69990,6 +75141,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -70058,6 +75210,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -70107,6 +75265,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -70174,6 +75333,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -70220,6 +75381,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -70332,6 +75494,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -70397,10 +75560,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -70447,6 +75613,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -70512,6 +75679,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); @@ -70561,6 +75729,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -70629,6 +75798,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; EventOutput copied = new(model); @@ -71263,3 +76438,98 @@ public void InvalidEnumSerializationRoundtrip_Works() Assert.Equal(value, deserialized); } } + +public class EventOutputLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new EventOutputLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new EventOutputLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 EventOutputLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new EventOutputLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + EventOutputLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs index 3dfa107ba..8b2dc15ce 100644 --- a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs @@ -51,6 +51,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, }; @@ -90,6 +91,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -137,6 +139,7 @@ public void Url_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, }; @@ -187,6 +190,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, }; @@ -237,6 +241,7 @@ public void NewFloatingUnitPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -292,6 +297,7 @@ public void NewFloatingTieredPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -335,6 +341,7 @@ public void NewFloatingBulkPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -385,6 +392,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -428,6 +436,7 @@ public void NewFloatingPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -476,6 +485,7 @@ public void NewFloatingMatrixPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -527,6 +537,7 @@ public void NewFloatingThresholdTotalAmountPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -578,6 +589,7 @@ public void NewFloatingTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -640,6 +652,7 @@ public void NewFloatingTieredWithMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -691,6 +704,7 @@ public void NewFloatingGroupedTieredPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -753,6 +767,7 @@ public void NewFloatingTieredPackageWithMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -802,6 +817,7 @@ public void NewFloatingPackageWithAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -845,6 +861,7 @@ public void NewFloatingUnitWithPercentPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -894,6 +911,7 @@ public void NewFloatingMatrixWithAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -939,6 +957,7 @@ public void NewFloatingTieredWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -982,6 +1001,7 @@ public void NewFloatingUnitWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1030,6 +1050,7 @@ public void NewFloatingGroupedAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1078,6 +1099,7 @@ public void NewFloatingBulkWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1127,6 +1149,7 @@ public void NewFloatingGroupedWithProratedMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1185,6 +1208,7 @@ public void NewFloatingGroupedWithMeteredMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1233,6 +1257,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1289,6 +1314,7 @@ public void NewFloatingMatrixWithDisplayNamePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1341,6 +1367,7 @@ public void NewFloatingGroupedTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1394,6 +1421,7 @@ public void NewFloatingMaxGroupTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1453,6 +1481,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1515,6 +1544,7 @@ public void NewFloatingScalableMatrixWithTieredPricingPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1571,6 +1601,7 @@ public void NewFloatingCumulativeGroupedBulkPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1619,6 +1650,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1662,6 +1694,7 @@ public void NewFloatingMinimumCompositePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1704,6 +1737,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1751,6 +1785,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1794,6 +1829,7 @@ public void NewFloatingUnitPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -1852,6 +1888,7 @@ public void NewFloatingTieredPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -1898,6 +1935,7 @@ public void NewFloatingBulkPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -1951,6 +1989,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -1997,6 +2036,7 @@ public void NewFloatingPackagePriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2048,6 +2088,7 @@ public void NewFloatingMatrixPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2102,6 +2143,7 @@ public void NewFloatingThresholdTotalAmountPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2156,6 +2198,7 @@ public void NewFloatingTieredPackagePriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2221,6 +2264,7 @@ public void NewFloatingTieredWithMinimumPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2275,6 +2319,7 @@ public void NewFloatingGroupedTieredPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2340,6 +2385,7 @@ public void NewFloatingTieredPackageWithMinimumPriceSerializationRoundtripWorks( Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2392,6 +2438,7 @@ public void NewFloatingPackageWithAllocationPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2438,6 +2485,7 @@ public void NewFloatingUnitWithPercentPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2490,6 +2538,7 @@ public void NewFloatingMatrixWithAllocationPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2538,6 +2587,7 @@ public void NewFloatingTieredWithProrationPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2584,6 +2634,7 @@ public void NewFloatingUnitWithProrationPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2635,6 +2686,7 @@ public void NewFloatingGroupedAllocationPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2686,6 +2738,7 @@ public void NewFloatingBulkWithProrationPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2738,6 +2791,7 @@ public void NewFloatingGroupedWithProratedMinimumPriceSerializationRoundtripWork Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2799,6 +2853,7 @@ public void NewFloatingGroupedWithMeteredMinimumPriceSerializationRoundtripWorks Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2850,6 +2905,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2909,6 +2965,7 @@ public void NewFloatingMatrixWithDisplayNamePriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2964,6 +3021,7 @@ public void NewFloatingGroupedTieredPackagePriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3020,6 +3078,7 @@ public void NewFloatingMaxGroupTieredPackagePriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3082,6 +3141,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceSerializationRoundtripW Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3147,6 +3207,7 @@ public void NewFloatingScalableMatrixWithTieredPricingPriceSerializationRoundtri Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3206,6 +3267,7 @@ public void NewFloatingCumulativeGroupedBulkPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3257,6 +3319,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3303,6 +3366,7 @@ public void NewFloatingMinimumCompositePriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3348,6 +3412,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3398,6 +3463,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3454,6 +3520,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3499,6 +3566,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); @@ -3517,6 +3585,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -3572,6 +3641,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3629,6 +3699,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3681,6 +3752,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); @@ -3702,6 +3774,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -3757,6 +3830,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3803,6 +3877,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -3859,6 +3935,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -3882,6 +3959,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -3915,6 +3994,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -3966,6 +4046,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4457,6 +4538,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4503,6 +4585,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -4524,6 +4607,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -4577,6 +4661,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4632,6 +4717,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4685,6 +4771,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -4709,6 +4796,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -4762,6 +4850,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4806,6 +4895,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -4858,6 +4949,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4881,6 +4973,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -4912,6 +5006,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4961,6 +5056,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5266,6 +5362,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5312,6 +5409,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -5333,6 +5431,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5386,6 +5485,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5441,6 +5541,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5494,6 +5595,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -5518,6 +5620,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5571,6 +5674,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5615,6 +5719,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -5667,6 +5773,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5690,6 +5797,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5721,6 +5830,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5770,6 +5880,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6069,6 +6180,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6106,6 +6218,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6124,6 +6237,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6171,6 +6285,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6217,6 +6332,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6261,6 +6377,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6282,6 +6399,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6329,6 +6447,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6367,6 +6486,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6407,6 +6528,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6430,6 +6552,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6455,6 +6579,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6498,6 +6623,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6756,6 +6882,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6798,6 +6925,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6816,6 +6944,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6868,6 +6997,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6922,6 +7052,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6971,6 +7102,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6992,6 +7124,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7044,6 +7177,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7087,6 +7221,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7137,6 +7273,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7160,6 +7297,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7190,6 +7329,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7238,6 +7378,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs index f1af1bf64..56e11020a 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs @@ -62,6 +62,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -116,6 +117,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -217,6 +219,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -280,6 +283,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -362,6 +366,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -421,6 +426,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -467,6 +473,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "price_id"; @@ -527,6 +534,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -585,6 +593,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -638,6 +647,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "price_id"; @@ -698,6 +708,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -749,6 +760,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -801,6 +813,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -852,6 +865,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -907,6 +921,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1030,6 +1045,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1081,6 +1097,7 @@ public void NewFloatingUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1136,6 +1153,7 @@ public void NewFloatingTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1179,6 +1197,7 @@ public void NewFloatingBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1229,6 +1248,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1272,6 +1292,7 @@ public void NewFloatingPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1320,6 +1341,7 @@ public void NewFloatingMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1371,6 +1393,7 @@ public void NewFloatingThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1422,6 +1445,7 @@ public void NewFloatingTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1484,6 +1508,7 @@ public void NewFloatingTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1535,6 +1560,7 @@ public void NewFloatingGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1597,6 +1623,7 @@ public void NewFloatingTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1646,6 +1673,7 @@ public void NewFloatingPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1689,6 +1717,7 @@ public void NewFloatingUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1738,6 +1767,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1783,6 +1813,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1826,6 +1857,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1874,6 +1906,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1922,6 +1955,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1971,6 +2005,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2029,6 +2064,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2077,6 +2113,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2133,6 +2170,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2185,6 +2223,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2238,6 +2277,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2297,6 +2337,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2359,6 +2400,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2415,6 +2457,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2463,6 +2506,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2506,6 +2550,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2548,6 +2593,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2595,6 +2641,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2638,6 +2685,7 @@ public void NewFloatingUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2696,6 +2744,7 @@ public void NewFloatingTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2742,6 +2791,7 @@ public void NewFloatingBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2795,6 +2845,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2841,6 +2892,7 @@ public void NewFloatingPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2892,6 +2944,7 @@ public void NewFloatingMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2946,6 +2999,7 @@ public void NewFloatingThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3000,6 +3054,7 @@ public void NewFloatingTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3065,6 +3120,7 @@ public void NewFloatingTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3119,6 +3175,7 @@ public void NewFloatingGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3184,6 +3241,7 @@ public void NewFloatingTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3236,6 +3294,7 @@ public void NewFloatingPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3282,6 +3341,7 @@ public void NewFloatingUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3334,6 +3394,7 @@ public void NewFloatingMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3382,6 +3443,7 @@ public void NewFloatingTieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3428,6 +3490,7 @@ public void NewFloatingUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3479,6 +3542,7 @@ public void NewFloatingGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3530,6 +3594,7 @@ public void NewFloatingBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3582,6 +3647,7 @@ public void NewFloatingGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3643,6 +3709,7 @@ public void NewFloatingGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3694,6 +3761,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3753,6 +3821,7 @@ public void NewFloatingMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3808,6 +3877,7 @@ public void NewFloatingGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3864,6 +3934,7 @@ public void NewFloatingMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3926,6 +3997,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3991,6 +4063,7 @@ public void NewFloatingScalableMatrixWithTieredPricingSerializationRoundtripWork Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4050,6 +4123,7 @@ public void NewFloatingCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4101,6 +4175,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4147,6 +4222,7 @@ public void NewFloatingMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4192,6 +4268,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4242,6 +4319,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4298,6 +4376,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4344,6 +4423,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); @@ -4362,6 +4442,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -4417,6 +4498,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4474,6 +4556,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4527,6 +4610,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); @@ -4548,6 +4632,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -4603,6 +4688,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4649,6 +4735,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -4705,6 +4793,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4728,6 +4817,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -4761,6 +4852,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4812,6 +4904,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5375,6 +5468,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5422,6 +5516,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -5443,6 +5538,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5496,6 +5592,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5551,6 +5648,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5605,6 +5703,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -5629,6 +5728,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5682,6 +5782,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5726,6 +5827,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -5778,6 +5881,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5801,6 +5905,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5832,6 +5938,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5881,6 +5988,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6186,6 +6294,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6233,6 +6342,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6254,6 +6364,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6307,6 +6418,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6362,6 +6474,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6416,6 +6529,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6440,6 +6554,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6493,6 +6608,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6537,6 +6653,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6589,6 +6707,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6612,6 +6731,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6643,6 +6764,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6692,6 +6814,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6991,6 +7114,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7028,6 +7152,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -7046,6 +7171,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7093,6 +7219,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7142,6 +7269,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7186,6 +7314,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -7207,6 +7336,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7254,6 +7384,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7292,6 +7423,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7332,6 +7465,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7355,6 +7489,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7380,6 +7516,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7423,6 +7560,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7681,6 +7819,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7723,6 +7862,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -7741,6 +7881,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7793,6 +7934,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7847,6 +7989,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7896,6 +8039,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -7917,6 +8061,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7969,6 +8114,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8012,6 +8158,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -8062,6 +8210,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8085,6 +8234,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -8115,6 +8266,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8163,6 +8315,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs index 5484d0e38..d1beeaa6e 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs @@ -76,6 +76,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -143,6 +144,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -269,6 +271,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -346,6 +349,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -442,6 +446,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -716,6 +721,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -763,6 +769,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "price_id"; @@ -822,6 +829,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -880,6 +888,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -935,6 +944,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "price_id"; @@ -994,6 +1004,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1044,6 +1055,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1095,6 +1107,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1145,6 +1158,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1199,6 +1213,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1321,6 +1336,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1372,6 +1388,7 @@ public void NewFloatingUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1427,6 +1444,7 @@ public void NewFloatingTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1470,6 +1488,7 @@ public void NewFloatingBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1522,6 +1541,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1565,6 +1585,7 @@ public void NewFloatingPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1613,6 +1634,7 @@ public void NewFloatingMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1665,6 +1687,7 @@ public void NewFloatingThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1717,6 +1740,7 @@ public void NewFloatingTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1780,6 +1804,7 @@ public void NewFloatingTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1832,6 +1857,7 @@ public void NewFloatingGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1895,6 +1921,7 @@ public void NewFloatingTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1944,6 +1971,7 @@ public void NewFloatingPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1988,6 +2016,7 @@ public void NewFloatingUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2041,6 +2070,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2087,6 +2117,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2131,6 +2162,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2180,6 +2212,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2229,6 +2262,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2279,6 +2313,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2342,6 +2377,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2392,6 +2428,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2448,6 +2485,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2501,6 +2539,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2554,6 +2593,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2614,6 +2654,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2677,6 +2718,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2733,6 +2775,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2783,6 +2826,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2831,6 +2875,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2874,6 +2919,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2923,6 +2969,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2966,6 +3013,7 @@ public void NewFloatingUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3028,6 +3076,7 @@ public void NewFloatingTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3078,6 +3127,7 @@ public void NewFloatingBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3137,6 +3187,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3187,6 +3238,7 @@ public void NewFloatingPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3242,6 +3294,7 @@ public void NewFloatingMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3301,6 +3354,7 @@ public void NewFloatingThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3360,6 +3414,7 @@ public void NewFloatingTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3430,6 +3485,7 @@ public void NewFloatingTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3489,6 +3545,7 @@ public void NewFloatingGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3559,6 +3616,7 @@ public void NewFloatingTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3615,6 +3673,7 @@ public void NewFloatingPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3666,6 +3725,7 @@ public void NewFloatingUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3726,6 +3786,7 @@ public void NewFloatingMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3779,6 +3840,7 @@ public void NewFloatingTieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3830,6 +3892,7 @@ public void NewFloatingUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3886,6 +3949,7 @@ public void NewFloatingGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3942,6 +4006,7 @@ public void NewFloatingBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3999,6 +4064,7 @@ public void NewFloatingGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4069,6 +4135,7 @@ public void NewFloatingGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4126,6 +4193,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4189,6 +4257,7 @@ public void NewFloatingMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4249,6 +4318,7 @@ public void NewFloatingGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4309,6 +4379,7 @@ public void NewFloatingMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4376,6 +4447,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4446,6 +4518,7 @@ public void NewFloatingScalableMatrixWithTieredPricingSerializationRoundtripWork Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4509,6 +4582,7 @@ public void NewFloatingCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4566,6 +4640,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4621,6 +4696,7 @@ public void NewFloatingMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4671,6 +4747,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4727,6 +4804,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4788,6 +4866,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4838,6 +4917,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); @@ -4856,6 +4936,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -4912,6 +4993,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4971,6 +5053,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5029,6 +5112,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); @@ -5050,6 +5134,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5106,6 +5191,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5153,6 +5239,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -5211,6 +5299,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5234,6 +5323,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5268,6 +5359,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5320,6 +5412,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5943,6 +6036,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5993,6 +6087,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6014,6 +6109,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6069,6 +6165,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6127,6 +6224,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6185,6 +6283,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6209,6 +6308,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6264,6 +6364,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6310,6 +6411,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6366,6 +6469,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6389,6 +6493,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6422,6 +6528,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6473,6 +6580,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6837,6 +6945,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6887,6 +6996,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6908,6 +7018,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6963,6 +7074,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7021,6 +7133,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7079,6 +7192,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -7103,6 +7217,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7158,6 +7273,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7204,6 +7320,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7260,6 +7378,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7283,6 +7402,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7316,6 +7437,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7367,6 +7489,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7722,6 +7845,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7764,6 +7888,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -7782,6 +7907,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7829,6 +7955,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7879,6 +8006,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7929,6 +8057,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -7950,6 +8079,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7997,6 +8127,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8035,6 +8166,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -8075,6 +8208,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8098,6 +8232,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -8123,6 +8259,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8166,6 +8303,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8452,6 +8590,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8499,6 +8638,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -8517,6 +8657,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8569,6 +8710,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8624,6 +8766,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8679,6 +8822,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -8700,6 +8844,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8752,6 +8897,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8795,6 +8941,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -8845,6 +8993,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8868,6 +9017,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -8898,6 +9049,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8946,6 +9098,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs b/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs index 6b7933e66..9a4f23a5d 100644 --- a/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs @@ -62,6 +62,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -129,6 +130,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -182,6 +189,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -249,6 +257,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ]; Models::PaginationMetadata expectedPaginationMetadata = new() @@ -318,6 +332,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -385,6 +400,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -452,6 +473,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -519,6 +541,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -579,6 +607,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -646,6 +675,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ]; Models::PaginationMetadata expectedPaginationMetadata = new() @@ -715,6 +750,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -782,6 +818,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -843,6 +885,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -910,6 +953,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, diff --git a/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs index b1bc9ed9e..4a5abb364 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs @@ -408,6 +408,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -475,6 +476,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -555,6 +562,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -622,6 +630,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -896,6 +910,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -977,6 +992,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1332,6 +1353,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1413,6 +1435,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1909,6 +1937,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1976,6 +2005,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -2054,6 +2089,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2121,6 +2157,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -2390,6 +2432,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2459,6 +2502,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2806,6 +2855,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2875,6 +2925,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3433,6 +3489,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3500,6 +3557,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -3580,6 +3643,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3647,6 +3711,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -3921,6 +3991,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4002,6 +4073,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4357,6 +4434,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4438,6 +4516,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4944,6 +5028,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5011,6 +5096,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -5091,6 +5182,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5158,6 +5250,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -5432,6 +5530,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5513,6 +5612,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -5868,6 +5973,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5949,6 +6055,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6452,6 +6564,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6519,6 +6632,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -6597,6 +6716,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6664,6 +6784,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -6933,6 +7059,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7002,6 +7129,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -7349,6 +7482,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7418,6 +7552,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -7985,6 +8125,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8052,6 +8193,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -8132,6 +8279,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8199,6 +8347,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -8473,6 +8627,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8554,6 +8709,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -8909,6 +9070,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8990,6 +9152,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9490,6 +9658,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9557,6 +9726,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -9637,6 +9812,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9704,6 +9880,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -10120,6 +10302,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10187,6 +10370,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -10267,6 +10456,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10334,6 +10524,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -10749,6 +10945,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10816,6 +11013,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -10896,6 +11099,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10963,6 +11167,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -11381,6 +11591,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11448,6 +11659,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -11528,6 +11745,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11595,6 +11813,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -12012,6 +12236,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12079,6 +12304,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -12159,6 +12390,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12226,6 +12458,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -12500,6 +12738,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12581,6 +12820,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -12936,6 +13181,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13017,6 +13263,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs index 22e1e7e7f..34d57bdd9 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs @@ -420,6 +420,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -488,6 +489,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -570,6 +577,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -638,6 +646,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -927,6 +941,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1025,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1380,6 +1401,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1485,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1969,6 +1997,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2065,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -2116,6 +2151,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,6 +2219,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -2457,6 +2499,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2581,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2893,6 +2942,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3024,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3502,6 +3558,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3627,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -3652,6 +3715,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,6 +3784,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -4009,6 +4079,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4163,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4462,6 +4539,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4623,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -5070,6 +5154,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5223,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -5220,6 +5311,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,6 +5380,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -5577,6 +5675,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5759,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6030,6 +6135,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6219,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6626,6 +6738,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6806,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -6773,6 +6892,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,6 +6960,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -7114,6 +7240,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7322,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -7550,6 +7683,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7765,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -8159,6 +8299,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8368,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -8309,6 +8456,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,6 +8525,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -8666,6 +8820,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8904,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9119,6 +9280,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9364,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9721,6 +9889,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9958,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -9871,6 +10046,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,6 +10115,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -10228,6 +10410,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10494,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -10681,6 +10870,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10954,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -11288,6 +11484,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11553,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -11438,6 +11641,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,6 +11710,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -11795,6 +12005,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12089,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -12248,6 +12465,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12549,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -12844,6 +13068,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13137,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -12994,6 +13225,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,6 +13294,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -13351,6 +13589,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13673,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -13804,6 +14049,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14133,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -14418,6 +14670,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14739,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -14568,6 +14827,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,6 +14896,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -14925,6 +15191,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15275,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -15378,6 +15651,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15735,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -15981,6 +16261,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16049,6 +16330,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -16131,6 +16418,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16199,6 +16487,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -16488,6 +16782,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16571,6 +16866,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -16941,6 +17242,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -17024,6 +17326,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs index 8c315d911..8a30a78ff 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs @@ -420,6 +420,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -488,6 +489,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -570,6 +577,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -638,6 +646,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -927,6 +941,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1025,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1380,6 +1401,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1485,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1969,6 +1997,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2065,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -2116,6 +2151,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,6 +2219,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -2457,6 +2499,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2581,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2893,6 +2942,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3024,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3502,6 +3558,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3627,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -3652,6 +3715,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,6 +3784,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -4009,6 +4079,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4163,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4462,6 +4539,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4623,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -5070,6 +5154,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5223,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -5220,6 +5311,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,6 +5380,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -5577,6 +5675,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5759,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6030,6 +6135,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6219,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6626,6 +6738,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6806,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -6773,6 +6892,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,6 +6960,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -7114,6 +7240,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7322,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -7550,6 +7683,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7765,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -8159,6 +8299,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8368,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -8309,6 +8456,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,6 +8525,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -8666,6 +8820,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8904,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9119,6 +9280,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9364,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9721,6 +9889,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9958,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -9871,6 +10046,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,6 +10115,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -10228,6 +10410,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10494,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -10681,6 +10870,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10954,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -11288,6 +11484,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11553,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -11438,6 +11641,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,6 +11710,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -11795,6 +12005,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12089,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -12248,6 +12465,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12549,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -12844,6 +13068,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13137,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -12994,6 +13225,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,6 +13294,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -13351,6 +13589,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13673,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -13804,6 +14049,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14133,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -14418,6 +14670,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14739,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -14568,6 +14827,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,6 +14896,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -14925,6 +15191,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15275,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -15378,6 +15651,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15735,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -15981,6 +16261,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16049,6 +16330,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -16131,6 +16418,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16199,6 +16487,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -16488,6 +16782,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16571,6 +16866,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -16941,6 +17242,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -17024,6 +17326,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs index 55c63020f..0b239667d 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs @@ -420,6 +420,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -488,6 +489,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -570,6 +577,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -638,6 +646,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -927,6 +941,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1025,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1380,6 +1401,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1485,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -1969,6 +1997,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2065,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -2116,6 +2151,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,6 +2219,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -2457,6 +2499,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2581,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -2893,6 +2942,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3024,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -3502,6 +3558,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3627,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -3652,6 +3715,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,6 +3784,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -4009,6 +4079,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4163,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -4462,6 +4539,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4623,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -5070,6 +5154,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5223,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -5220,6 +5311,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,6 +5380,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -5577,6 +5675,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5759,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6030,6 +6135,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6219,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -6626,6 +6738,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6806,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -6773,6 +6892,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,6 +6960,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -7114,6 +7240,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7322,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -7550,6 +7683,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7765,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -8159,6 +8299,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8368,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -8309,6 +8456,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,6 +8525,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -8666,6 +8820,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8904,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9119,6 +9280,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9364,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -9721,6 +9889,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9958,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -9871,6 +10046,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,6 +10115,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -10228,6 +10410,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10494,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -10681,6 +10870,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10954,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -11288,6 +11484,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11553,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -11438,6 +11641,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,6 +11710,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -11795,6 +12005,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12089,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -12248,6 +12465,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12549,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -12844,6 +13068,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13137,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -12994,6 +13225,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,6 +13294,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -13351,6 +13589,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13673,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -13804,6 +14049,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14133,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -14418,6 +14670,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14739,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -14568,6 +14827,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,6 +14896,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -14925,6 +15191,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15275,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -15378,6 +15651,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15735,12 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -15981,6 +16261,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16049,6 +16330,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -16131,6 +16418,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16199,6 +16487,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -16488,6 +16782,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -16571,6 +16866,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), @@ -16941,6 +17242,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -17024,6 +17326,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, Quantity = 1, StartDate = DateTimeOffset.Parse("2022-02-01T08:00:00+00:00"), diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkPriceTest.cs index ba7324290..18e36ff56 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkPriceTest.cs @@ -47,6 +47,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -88,6 +89,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -107,6 +109,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -156,6 +159,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -207,6 +211,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -255,6 +260,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -277,6 +283,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -326,6 +333,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -367,6 +375,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -410,6 +420,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -436,6 +447,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -464,6 +477,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -509,6 +523,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkWithProrationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkWithProrationPriceTest.cs index b79405029..7aea6f566 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionBulkWithProrationPriceTest.cs @@ -53,6 +53,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -103,6 +104,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -122,6 +124,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -177,6 +180,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -235,6 +239,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -293,6 +298,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -315,6 +321,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -370,6 +377,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -417,6 +425,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -472,6 +482,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -498,6 +509,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -532,6 +545,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -583,6 +597,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPriceTest.cs index 033aa7125..f2d2e44d4 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPriceTest.cs @@ -60,6 +60,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -117,6 +118,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -136,6 +138,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -198,6 +201,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -263,6 +267,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -328,6 +333,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -350,6 +356,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -412,6 +419,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -466,6 +474,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -535,6 +545,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -561,6 +572,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -602,6 +615,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -660,6 +674,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedAllocationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedAllocationPriceTest.cs index c69292ebd..6c2c5d216 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedAllocationPriceTest.cs @@ -53,6 +53,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -103,6 +104,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -122,6 +124,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -177,6 +180,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -235,6 +239,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -293,6 +298,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -315,6 +321,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -370,6 +377,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -417,6 +425,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -472,6 +482,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -498,6 +509,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -532,6 +545,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -583,6 +597,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePriceTest.cs index d997046eb..1178cffdf 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePriceTest.cs @@ -57,6 +57,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -111,6 +112,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -130,6 +132,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -189,6 +192,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -251,6 +255,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -313,6 +318,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -335,6 +341,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -394,6 +401,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -445,6 +453,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -508,6 +518,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -534,6 +545,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -572,6 +585,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -627,6 +641,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPriceTest.cs index 27a5ba4db..6b7e559f5 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedTieredPriceTest.cs @@ -55,6 +55,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -106,6 +107,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -125,6 +127,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -182,6 +185,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -242,6 +246,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -301,6 +306,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -323,6 +329,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -380,6 +387,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -429,6 +437,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -488,6 +498,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -514,6 +525,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -550,6 +563,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -603,6 +617,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPriceTest.cs index 5cf84eb59..9b400c89b 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPriceTest.cs @@ -62,6 +62,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -123,6 +124,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -145,6 +147,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -209,6 +212,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -276,6 +280,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -345,6 +350,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -370,6 +376,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -434,6 +441,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -490,6 +498,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -563,6 +573,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -589,6 +600,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -632,6 +645,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -692,6 +706,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPriceTest.cs index 3e9a4a2f9..4bd49c6be 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPriceTest.cs @@ -53,6 +53,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -105,6 +106,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -127,6 +129,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -182,6 +185,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -240,6 +244,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -300,6 +305,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -325,6 +331,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -380,6 +387,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -427,6 +435,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -482,6 +492,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -508,6 +519,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -542,6 +555,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -593,6 +607,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixPriceTest.cs index 0cc0c8c3a..3bb16bd4a 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixPriceTest.cs @@ -52,6 +52,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -97,6 +98,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -116,6 +118,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -170,6 +173,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -226,6 +230,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -278,6 +283,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -300,6 +306,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -354,6 +361,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -400,6 +408,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -453,6 +463,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -479,6 +490,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -512,6 +525,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -562,6 +576,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPriceTest.cs index 9e03261cb..2c3cb9358 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPriceTest.cs @@ -53,6 +53,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -99,6 +100,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -118,6 +120,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -173,6 +176,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -230,6 +234,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -283,6 +288,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -305,6 +311,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -360,6 +367,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -407,6 +415,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -462,6 +472,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -488,6 +499,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -522,6 +535,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -573,6 +587,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePriceTest.cs index d92366fec..4357a995e 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePriceTest.cs @@ -60,6 +60,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -117,6 +118,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -136,6 +138,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -198,6 +201,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -263,6 +267,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -328,6 +333,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -350,6 +356,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -412,6 +419,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -466,6 +474,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -535,6 +545,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -561,6 +572,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -602,6 +615,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -660,6 +674,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePriceTest.cs index 77f355429..47a05803a 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePriceTest.cs @@ -57,6 +57,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -111,6 +112,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -130,6 +132,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -189,6 +192,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -251,6 +255,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -313,6 +318,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -335,6 +341,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -394,6 +401,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -445,6 +453,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -508,6 +518,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -534,6 +545,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -572,6 +585,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -627,6 +641,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMinimumCompositePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMinimumCompositePriceTest.cs index a3ef343c3..c0d95e35f 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMinimumCompositePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionMinimumCompositePriceTest.cs @@ -48,6 +48,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -97,6 +98,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -116,6 +118,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -166,6 +169,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -219,6 +223,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -276,6 +281,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -298,6 +304,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -348,6 +355,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -390,6 +398,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -435,6 +445,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -461,6 +472,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -490,6 +503,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -536,6 +550,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackagePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackagePriceTest.cs index 189fcaf5f..d00c236ff 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackagePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackagePriceTest.cs @@ -47,6 +47,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -91,6 +92,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -110,6 +112,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -159,6 +162,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -210,6 +214,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -261,6 +266,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -283,6 +289,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -332,6 +339,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -373,6 +381,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -416,6 +426,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -442,6 +453,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -470,6 +483,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -515,6 +529,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackageWithAllocationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackageWithAllocationPriceTest.cs index 40986b2b6..c7eb223e7 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackageWithAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionPackageWithAllocationPriceTest.cs @@ -53,6 +53,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -103,6 +104,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -122,6 +124,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -177,6 +180,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -235,6 +239,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -293,6 +298,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -315,6 +321,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -370,6 +377,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -417,6 +425,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -472,6 +482,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -498,6 +509,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -532,6 +545,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -583,6 +597,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.cs index 501c78839..b2e80385f 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.cs @@ -67,6 +67,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -132,6 +133,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -154,6 +156,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -223,6 +226,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -295,6 +299,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -368,6 +373,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -393,6 +399,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -462,6 +469,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -523,6 +531,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -606,6 +616,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -632,6 +643,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -680,6 +693,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -745,6 +759,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs index 2beb8456a..10be34dce 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs @@ -64,6 +64,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -126,6 +127,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -148,6 +150,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -214,6 +217,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -283,6 +287,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -353,6 +358,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -378,6 +384,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -444,6 +451,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -502,6 +510,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -579,6 +589,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -605,6 +616,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -650,6 +663,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -712,6 +726,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPriceTest.cs index e70c2bf9f..07bcd103f 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPriceTest.cs @@ -56,6 +56,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -109,6 +110,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -128,6 +130,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -186,6 +189,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -247,6 +251,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -308,6 +313,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -330,6 +336,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -388,6 +395,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -438,6 +446,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -499,6 +509,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -525,6 +536,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -562,6 +575,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -616,6 +630,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackagePriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackagePriceTest.cs index ca23c4010..46dee6d46 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackagePriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackagePriceTest.cs @@ -55,6 +55,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -106,6 +107,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -125,6 +127,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -182,6 +185,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -242,6 +246,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -301,6 +306,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -323,6 +329,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -380,6 +387,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -429,6 +437,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -488,6 +498,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -514,6 +525,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -550,6 +563,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -603,6 +617,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPriceTest.cs index d2805d237..8da31f162 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPriceTest.cs @@ -66,6 +66,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -130,6 +131,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -149,6 +151,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -217,6 +220,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -288,6 +292,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -360,6 +365,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -385,6 +391,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -453,6 +460,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -513,6 +521,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -594,6 +604,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -620,6 +631,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -667,6 +680,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -731,6 +745,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPriceTest.cs index 82bc82207..944a8aed0 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredPriceTest.cs @@ -59,6 +59,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -111,6 +112,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -130,6 +132,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -191,6 +194,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -254,6 +258,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -313,6 +318,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -335,6 +341,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -396,6 +403,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -449,6 +457,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -516,6 +526,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -542,6 +553,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -582,6 +595,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -639,6 +653,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredWithMinimumPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredWithMinimumPriceTest.cs index 07b469b0e..14427d788 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredWithMinimumPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionTieredWithMinimumPriceTest.cs @@ -67,6 +67,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -131,6 +132,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -150,6 +152,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -219,6 +222,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -291,6 +295,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -363,6 +368,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -385,6 +391,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -454,6 +461,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -515,6 +523,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -598,6 +608,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -624,6 +635,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -672,6 +685,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -737,6 +751,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitPriceTest.cs index 5f668bcc9..4d8d97dd7 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitPriceTest.cs @@ -47,6 +47,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -87,6 +88,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -106,6 +108,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -155,6 +158,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -206,6 +210,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -253,6 +258,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -275,6 +281,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -324,6 +331,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -365,6 +373,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -408,6 +418,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -434,6 +445,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -462,6 +475,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -507,6 +521,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithPercentPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithPercentPriceTest.cs index f59f8fb0b..47879d1cb 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithPercentPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithPercentPriceTest.cs @@ -47,6 +47,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -94,6 +95,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -113,6 +115,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -162,6 +165,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -214,6 +218,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -269,6 +274,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -291,6 +297,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -340,6 +347,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -381,6 +389,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -424,6 +434,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -450,6 +461,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -478,6 +491,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -523,6 +537,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithProrationPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithProrationPriceTest.cs index a69e6c049..4124790e2 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithProrationPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionUnitWithProrationPriceTest.cs @@ -48,6 +48,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -93,6 +94,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -112,6 +114,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -162,6 +165,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -215,6 +219,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -268,6 +273,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -290,6 +296,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -340,6 +347,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -382,6 +390,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -427,6 +437,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -453,6 +464,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -482,6 +495,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -528,6 +542,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs index 621241f56..ab5b0dfa7 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs @@ -69,6 +69,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -122,6 +123,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -216,6 +218,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -268,6 +271,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -333,6 +337,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -385,6 +390,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -480,6 +486,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -531,6 +538,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -693,6 +701,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -746,6 +755,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -839,6 +849,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -891,6 +902,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -967,6 +979,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -1020,6 +1033,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1113,6 +1127,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -1165,6 +1180,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1435,6 +1451,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -1488,6 +1505,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1582,6 +1600,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -1634,6 +1653,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2349,6 +2369,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2401,6 +2422,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2429,6 +2451,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -2481,6 +2504,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2530,6 +2554,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2582,6 +2607,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2624,6 +2650,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2676,6 +2703,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2711,6 +2739,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -2763,6 +2792,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2812,6 +2842,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2864,6 +2895,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2994,6 +3026,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -3046,6 +3079,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -3099,6 +3133,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3155,6 +3190,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3199,6 +3235,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3250,6 +3287,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3294,6 +3332,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3343,6 +3382,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3396,6 +3436,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3448,6 +3489,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3512,6 +3554,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3564,6 +3607,7 @@ public void NewSubscriptionGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3628,6 +3672,7 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3678,6 +3723,7 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3722,6 +3768,7 @@ public void NewSubscriptionUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3773,6 +3820,7 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3818,6 +3866,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3863,6 +3912,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3913,6 +3963,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3963,6 +4014,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4015,6 +4067,7 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4080,6 +4133,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4129,6 +4183,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4186,6 +4241,7 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4240,6 +4296,7 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4294,6 +4351,7 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4356,6 +4414,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4421,6 +4480,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4478,6 +4538,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4527,6 +4588,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4572,6 +4634,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4615,6 +4678,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4663,6 +4727,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4707,6 +4772,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4769,6 +4835,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4819,6 +4886,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4876,6 +4944,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4926,6 +4995,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4981,6 +5051,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5040,6 +5111,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5098,6 +5170,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5168,6 +5241,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5226,6 +5300,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5296,6 +5371,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5352,6 +5428,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5402,6 +5479,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5459,6 +5537,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5510,6 +5589,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5561,6 +5641,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5617,6 +5698,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5673,6 +5755,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5731,6 +5814,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5802,6 +5886,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5857,6 +5942,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5920,6 +6006,7 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5980,6 +6067,7 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6040,6 +6128,7 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6108,6 +6197,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6179,6 +6269,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6242,6 +6333,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6297,6 +6389,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6348,6 +6441,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6397,6 +6491,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6451,6 +6546,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6511,6 +6607,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6557,6 +6654,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6576,6 +6674,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6632,6 +6731,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6690,6 +6790,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6743,6 +6844,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6765,6 +6867,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6821,6 +6924,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6869,6 +6973,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6926,6 +7032,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6952,6 +7059,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6987,6 +7096,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7039,6 +7149,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7565,6 +7676,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7606,6 +7718,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7625,6 +7738,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7675,6 +7789,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7727,6 +7842,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7775,6 +7891,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7797,6 +7914,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7847,6 +7965,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7889,6 +8008,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7934,6 +8055,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7960,6 +8082,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7989,6 +8113,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8035,6 +8160,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8412,6 +8538,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8460,6 +8587,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8482,6 +8610,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8536,6 +8665,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8592,6 +8722,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8647,6 +8778,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8672,6 +8804,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8726,6 +8859,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8772,6 +8906,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8825,6 +8961,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8851,6 +8988,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8884,6 +9023,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8934,6 +9074,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9242,6 +9383,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9290,6 +9432,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9312,6 +9455,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -9366,6 +9510,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9422,6 +9567,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9477,6 +9623,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9502,6 +9649,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9556,6 +9704,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9602,6 +9751,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9655,6 +9806,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9681,6 +9833,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9714,6 +9868,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9764,6 +9919,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10066,6 +10222,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10105,6 +10262,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -10124,6 +10282,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -10172,6 +10331,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10222,6 +10382,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10268,6 +10429,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -10290,6 +10452,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -10338,6 +10501,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10378,6 +10542,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -10419,6 +10585,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10445,6 +10612,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -10472,6 +10641,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10516,6 +10686,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10773,6 +10944,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10817,6 +10989,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -10836,6 +11009,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -10889,6 +11063,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10944,6 +11119,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10995,6 +11171,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -11017,6 +11194,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -11070,6 +11248,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11115,6 +11294,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -11166,6 +11347,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -11192,6 +11374,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -11224,6 +11408,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -11273,6 +11458,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12360,6 +12546,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12411,6 +12598,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -12439,6 +12627,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -12491,6 +12680,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12539,6 +12729,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12590,6 +12781,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -12632,6 +12824,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12683,6 +12876,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -12718,6 +12912,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -12770,6 +12965,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12818,6 +13014,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12869,6 +13066,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -12991,6 +13189,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -13042,6 +13241,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -13094,6 +13294,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13150,6 +13351,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13194,6 +13396,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13246,6 +13449,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13290,6 +13494,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13339,6 +13544,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13393,6 +13599,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13446,6 +13653,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13511,6 +13719,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13564,6 +13773,7 @@ public void NewSubscriptionGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13628,6 +13838,7 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13679,6 +13890,7 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13725,6 +13937,7 @@ public void NewSubscriptionUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13780,6 +13993,7 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13826,6 +14040,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13872,6 +14087,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13923,6 +14139,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13974,6 +14191,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14026,6 +14244,7 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14091,6 +14310,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14141,6 +14361,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14199,6 +14420,7 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14254,6 +14476,7 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14309,6 +14532,7 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14371,6 +14595,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14436,6 +14661,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14494,6 +14720,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14544,6 +14771,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14594,6 +14822,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14637,6 +14866,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14685,6 +14915,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14729,6 +14960,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14791,6 +15023,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14841,6 +15074,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14899,6 +15133,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14949,6 +15184,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15004,6 +15240,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15064,6 +15301,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15123,6 +15361,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15194,6 +15433,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15253,6 +15493,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15323,6 +15564,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15380,6 +15622,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15432,6 +15675,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15493,6 +15737,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15545,6 +15790,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15597,6 +15843,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15654,6 +15901,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15711,6 +15959,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15769,6 +16018,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15840,6 +16090,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15896,6 +16147,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15960,6 +16212,7 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16021,6 +16274,7 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16082,6 +16336,7 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16150,6 +16405,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16221,6 +16477,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16285,6 +16542,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16341,6 +16599,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16397,6 +16656,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16446,6 +16706,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16500,6 +16761,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16560,6 +16822,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16608,6 +16871,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -16627,6 +16891,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -16683,6 +16948,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16742,6 +17008,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16798,6 +17065,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -16820,6 +17088,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -16876,6 +17145,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16924,6 +17194,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -16981,6 +17253,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17007,6 +17280,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17042,6 +17317,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17094,6 +17370,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17660,6 +17937,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17702,6 +17980,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17721,6 +18000,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -17771,6 +18051,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17824,6 +18105,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17874,6 +18156,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17896,6 +18179,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -17946,6 +18230,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17988,6 +18273,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18033,6 +18320,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18059,6 +18347,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18088,6 +18378,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18134,6 +18425,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18529,6 +18821,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18580,6 +18873,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18602,6 +18896,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -18656,6 +18951,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18713,6 +19009,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18772,6 +19069,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18797,6 +19095,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -18851,6 +19150,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18897,6 +19197,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18950,6 +19252,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18976,6 +19279,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19009,6 +19314,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19059,6 +19365,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19378,6 +19685,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19429,6 +19737,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19451,6 +19760,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -19505,6 +19815,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19562,6 +19873,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19621,6 +19933,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19646,6 +19959,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -19700,6 +20014,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19746,6 +20061,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19799,6 +20116,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19825,6 +20143,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19858,6 +20178,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19908,6 +20229,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20221,6 +20543,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20260,6 +20583,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -20279,6 +20603,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -20327,6 +20652,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20377,6 +20703,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20423,6 +20750,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -20445,6 +20773,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -20493,6 +20822,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20533,6 +20863,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -20574,6 +20906,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20600,6 +20933,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -20627,6 +20962,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20671,6 +21007,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20936,6 +21273,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20981,6 +21319,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21000,6 +21339,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -21053,6 +21393,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21108,6 +21449,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21160,6 +21502,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21182,6 +21525,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -21235,6 +21579,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21280,6 +21625,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -21331,6 +21678,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21357,6 +21705,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -21389,6 +21739,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21438,6 +21789,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs index 49d4910c1..b35151def 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs @@ -68,6 +68,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -135,6 +136,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -204,6 +211,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -271,6 +279,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -351,6 +365,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -418,6 +433,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -501,6 +522,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -568,6 +590,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -644,6 +672,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -711,6 +740,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -791,6 +826,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -858,6 +894,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", @@ -935,6 +977,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1002,6 +1045,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, PriceID = "price_id", Subtotal = "subtotal", diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs index 4a23ba521..ab1bc7c36 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs @@ -42,6 +42,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -95,6 +96,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -191,6 +193,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -243,6 +246,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -418,6 +422,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -471,6 +476,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -576,6 +582,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -629,6 +636,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -753,6 +761,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -806,6 +815,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -910,6 +920,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -962,6 +973,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -992,6 +1004,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; bool expectedCanDeferBilling = true; @@ -1044,6 +1057,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "h74gfhdjvn7ujokd"; @@ -1112,6 +1126,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -1164,6 +1179,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1206,6 +1222,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -1258,6 +1275,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1295,6 +1313,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; bool expectedCanDeferBilling = true; @@ -1347,6 +1366,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "h74gfhdjvn7ujokd"; @@ -1415,6 +1435,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -1467,6 +1488,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1619,6 +1641,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -1671,6 +1694,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -2156,6 +2180,7 @@ public void NewFloatingUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2211,6 +2236,7 @@ public void NewFloatingTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2254,6 +2280,7 @@ public void NewFloatingBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2304,6 +2331,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2347,6 +2375,7 @@ public void NewFloatingPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2395,6 +2424,7 @@ public void NewFloatingMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2446,6 +2476,7 @@ public void NewFloatingThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2497,6 +2528,7 @@ public void NewFloatingTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2559,6 +2591,7 @@ public void NewFloatingTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2610,6 +2643,7 @@ public void NewFloatingGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2671,6 +2705,7 @@ public void NewFloatingTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2719,6 +2754,7 @@ public void NewFloatingPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2762,6 +2798,7 @@ public void NewFloatingUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2811,6 +2848,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2856,6 +2894,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2899,6 +2938,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2947,6 +2987,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2995,6 +3036,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3044,6 +3086,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3102,6 +3145,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3150,6 +3194,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3205,6 +3250,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3257,6 +3303,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3309,6 +3356,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3368,6 +3416,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3430,6 +3479,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3485,6 +3535,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3533,6 +3584,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3576,6 +3628,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3618,6 +3671,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3665,6 +3719,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3708,6 +3763,7 @@ public void NewFloatingUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3769,6 +3825,7 @@ public void NewFloatingTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3818,6 +3875,7 @@ public void NewFloatingBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3874,6 +3932,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3923,6 +3982,7 @@ public void NewFloatingPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3977,6 +4037,7 @@ public void NewFloatingMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4034,6 +4095,7 @@ public void NewFloatingThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4091,6 +4153,7 @@ public void NewFloatingTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4159,6 +4222,7 @@ public void NewFloatingTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4216,6 +4280,7 @@ public void NewFloatingGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4283,6 +4348,7 @@ public void NewFloatingTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4337,6 +4403,7 @@ public void NewFloatingPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4386,6 +4453,7 @@ public void NewFloatingUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4441,6 +4509,7 @@ public void NewFloatingMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4492,6 +4561,7 @@ public void NewFloatingTieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4541,6 +4611,7 @@ public void NewFloatingUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4595,6 +4666,7 @@ public void NewFloatingGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4649,6 +4721,7 @@ public void NewFloatingBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4704,6 +4777,7 @@ public void NewFloatingGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4768,6 +4842,7 @@ public void NewFloatingGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4822,6 +4897,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4883,6 +4959,7 @@ public void NewFloatingMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4941,6 +5018,7 @@ public void NewFloatingGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4999,6 +5077,7 @@ public void NewFloatingMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5064,6 +5143,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5132,6 +5212,7 @@ public void NewFloatingScalableMatrixWithTieredPricingSerializationRoundtripWork Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5193,6 +5274,7 @@ public void NewFloatingCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5247,6 +5329,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5296,6 +5379,7 @@ public void NewFloatingMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5344,6 +5428,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5397,6 +5482,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5456,6 +5542,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5503,6 +5590,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); @@ -5521,6 +5609,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5576,6 +5665,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5633,6 +5723,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5687,6 +5778,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); @@ -5708,6 +5800,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5763,6 +5856,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5809,6 +5903,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -5865,6 +5961,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5888,6 +5985,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5921,6 +6020,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5972,6 +6072,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6537,6 +6638,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6586,6 +6688,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6607,6 +6710,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6660,6 +6764,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6716,6 +6821,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6773,6 +6879,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6797,6 +6904,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6850,6 +6958,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6894,6 +7003,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6946,6 +7057,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6969,6 +7081,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7000,6 +7114,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7049,6 +7164,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7366,6 +7482,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7415,6 +7532,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -7436,6 +7554,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7489,6 +7608,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7545,6 +7665,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7602,6 +7723,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -7626,6 +7748,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7679,6 +7802,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7723,6 +7847,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7775,6 +7901,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7798,6 +7925,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7829,6 +7958,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7878,6 +8008,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8189,6 +8320,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8227,6 +8359,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -8245,6 +8378,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8292,6 +8426,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8341,6 +8476,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8386,6 +8522,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -8407,6 +8544,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8454,6 +8592,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8492,6 +8631,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -8532,6 +8673,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8555,6 +8697,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -8580,6 +8724,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8623,6 +8768,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8885,6 +9031,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8928,6 +9075,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -8946,6 +9094,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8998,6 +9147,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9052,6 +9202,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9102,6 +9253,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -9123,6 +9275,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9175,6 +9328,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9218,6 +9372,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -9268,6 +9424,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -9291,6 +9448,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -9321,6 +9480,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -9369,6 +9529,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs index 8eec26e8e..839aed0fd 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs @@ -72,6 +72,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -125,6 +126,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -212,6 +214,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -264,6 +267,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -334,6 +338,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -386,6 +391,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -477,6 +483,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -528,6 +535,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -846,6 +854,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -899,6 +908,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -986,6 +996,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -1038,6 +1049,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1837,6 +1849,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -1889,6 +1902,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1917,6 +1931,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -1970,6 +1985,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2019,6 +2035,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2071,6 +2088,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2114,6 +2132,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2166,6 +2185,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2202,6 +2222,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -2255,6 +2276,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2304,6 +2326,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2356,6 +2379,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2486,6 +2510,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2538,6 +2563,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2592,6 +2618,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2649,6 +2676,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2694,6 +2722,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2747,6 +2776,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2792,6 +2822,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2845,6 +2876,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2899,6 +2931,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2952,6 +2985,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3017,6 +3051,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3070,6 +3105,7 @@ public void NewSubscriptionGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3134,6 +3170,7 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3185,6 +3222,7 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3231,6 +3269,7 @@ public void NewSubscriptionUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3286,6 +3325,7 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3333,6 +3373,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3379,6 +3420,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3430,6 +3472,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3481,6 +3524,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3533,6 +3577,7 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3598,6 +3643,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3649,6 +3695,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3707,6 +3754,7 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3762,6 +3810,7 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3817,6 +3866,7 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3879,6 +3929,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3944,6 +3995,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4002,6 +4054,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4053,6 +4106,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4103,6 +4157,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4148,6 +4203,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4198,6 +4254,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4243,6 +4300,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4307,6 +4365,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4359,6 +4418,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4419,6 +4479,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4471,6 +4532,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4531,6 +4593,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4592,6 +4655,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4652,6 +4716,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4724,6 +4789,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4784,6 +4850,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4855,6 +4922,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4913,6 +4981,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4966,6 +5035,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5028,6 +5098,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5082,6 +5153,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5135,6 +5207,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5193,6 +5266,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5251,6 +5325,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5310,6 +5385,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5382,6 +5458,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5440,6 +5517,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5505,6 +5583,7 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5567,6 +5646,7 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5629,6 +5709,7 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5698,6 +5779,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5770,6 +5852,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5835,6 +5918,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5893,6 +5977,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5950,6 +6035,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6002,6 +6088,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6059,6 +6146,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6122,6 +6210,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6173,6 +6262,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6192,6 +6282,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6250,6 +6341,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6311,6 +6403,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6370,6 +6463,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6392,6 +6486,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6450,6 +6545,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6500,6 +6596,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6561,6 +6659,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6587,6 +6686,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6624,6 +6725,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6678,6 +6780,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7313,6 +7416,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7356,6 +7460,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7375,6 +7480,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7427,6 +7533,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7482,6 +7589,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7533,6 +7641,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7555,6 +7664,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7607,6 +7717,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7651,6 +7762,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7700,6 +7813,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7726,6 +7840,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7757,6 +7873,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7805,6 +7922,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8252,6 +8370,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8303,6 +8422,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8325,6 +8445,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8381,6 +8502,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8440,6 +8562,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8499,6 +8622,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8524,6 +8648,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8580,6 +8705,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8628,6 +8754,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8685,6 +8813,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8711,6 +8840,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8746,6 +8877,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8798,6 +8930,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9163,6 +9296,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9214,6 +9348,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9236,6 +9371,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -9292,6 +9428,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9351,6 +9488,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9410,6 +9548,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -9435,6 +9574,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9491,6 +9631,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9539,6 +9680,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9596,6 +9739,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9622,6 +9766,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9657,6 +9803,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9709,6 +9856,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10066,6 +10214,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10109,6 +10258,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -10128,6 +10278,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -10177,6 +10328,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10229,6 +10381,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10280,6 +10433,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -10302,6 +10456,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -10351,6 +10506,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10392,6 +10548,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -10435,6 +10593,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10461,6 +10620,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -10489,6 +10650,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10534,6 +10696,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10866,6 +11029,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10914,6 +11078,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -10933,6 +11098,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -10987,6 +11153,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11044,6 +11211,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11100,6 +11268,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -11122,6 +11291,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -11176,6 +11346,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11222,6 +11393,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -11275,6 +11448,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -11301,6 +11475,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -11334,6 +11510,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -11384,6 +11561,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12583,6 +12761,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12634,6 +12813,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -12662,6 +12842,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -12714,6 +12895,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12762,6 +12944,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12813,6 +12996,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -12856,6 +13040,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12907,6 +13092,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -12943,6 +13129,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -12995,6 +13182,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13043,6 +13231,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -13094,6 +13283,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -13222,6 +13412,7 @@ public void CopyConstructor_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -13273,6 +13464,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -13326,6 +13518,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13383,6 +13576,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13428,6 +13622,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13481,6 +13676,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13526,6 +13722,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13579,6 +13776,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13633,6 +13831,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13686,6 +13885,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13751,6 +13951,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13804,6 +14005,7 @@ public void NewSubscriptionGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13868,6 +14070,7 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13919,6 +14122,7 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13965,6 +14169,7 @@ public void NewSubscriptionUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14020,6 +14225,7 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14067,6 +14273,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14113,6 +14320,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14164,6 +14372,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14215,6 +14424,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14267,6 +14477,7 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14332,6 +14543,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14383,6 +14595,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14441,6 +14654,7 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14496,6 +14710,7 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14551,6 +14766,7 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14613,6 +14829,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14678,6 +14895,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14736,6 +14954,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14787,6 +15006,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14837,6 +15057,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14882,6 +15103,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14932,6 +15154,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14977,6 +15200,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15041,6 +15265,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15093,6 +15318,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15153,6 +15379,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15205,6 +15432,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15265,6 +15493,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15326,6 +15555,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15386,6 +15616,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15458,6 +15689,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15518,6 +15750,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15589,6 +15822,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15647,6 +15881,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15700,6 +15935,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15762,6 +15998,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15816,6 +16053,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15869,6 +16107,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15927,6 +16166,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15985,6 +16225,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16044,6 +16285,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16116,6 +16358,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16174,6 +16417,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16239,6 +16483,7 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16301,6 +16546,7 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16363,6 +16609,7 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16432,6 +16679,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16504,6 +16752,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16569,6 +16818,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16627,6 +16877,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16684,6 +16935,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16736,6 +16988,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16793,6 +17046,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16856,6 +17110,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16907,6 +17162,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -16926,6 +17182,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -16984,6 +17241,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17045,6 +17303,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17104,6 +17363,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -17126,6 +17386,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -17184,6 +17445,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17234,6 +17496,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17295,6 +17559,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17321,6 +17586,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17358,6 +17625,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17412,6 +17680,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18048,6 +18317,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18091,6 +18361,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18110,6 +18381,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -18162,6 +18434,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18217,6 +18490,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18268,6 +18542,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -18290,6 +18565,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -18342,6 +18618,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18386,6 +18663,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18435,6 +18714,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18461,6 +18741,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18492,6 +18774,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18540,6 +18823,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18987,6 +19271,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19038,6 +19323,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19060,6 +19346,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -19116,6 +19403,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19175,6 +19463,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19234,6 +19523,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19259,6 +19549,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -19315,6 +19606,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19363,6 +19655,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19420,6 +19714,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19446,6 +19741,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -19481,6 +19778,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19533,6 +19831,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19898,6 +20197,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19949,6 +20249,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -19971,6 +20272,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -20027,6 +20329,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20086,6 +20389,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20145,6 +20449,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -20170,6 +20475,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -20226,6 +20532,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20274,6 +20581,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -20331,6 +20640,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20357,6 +20667,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -20392,6 +20704,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20444,6 +20757,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20801,6 +21115,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20844,6 +21159,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -20863,6 +21179,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -20912,6 +21229,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20964,6 +21282,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21015,6 +21334,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21037,6 +21357,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -21086,6 +21407,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21127,6 +21449,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -21170,6 +21494,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21196,6 +21521,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -21224,6 +21551,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21269,6 +21597,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21605,6 +21934,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21653,6 +21983,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21672,6 +22003,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -21727,6 +22059,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21785,6 +22118,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21841,6 +22175,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21863,6 +22198,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -21918,6 +22254,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21965,6 +22302,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -22020,6 +22359,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -22046,6 +22386,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -22080,6 +22422,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -22131,6 +22474,7 @@ public void CopyConstructor_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs index 52a4464d0..bae4dda00 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs @@ -420,6 +420,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -487,6 +488,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -575,6 +582,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -642,6 +650,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -1059,6 +1073,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1126,6 +1141,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1212,6 +1233,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1279,6 +1301,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -1718,6 +1746,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1785,6 +1814,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1873,6 +1908,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1940,6 +1976,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -2377,6 +2419,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2444,6 +2487,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -2532,6 +2581,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2599,6 +2649,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -3023,6 +3079,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3090,6 +3147,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -3176,6 +3239,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3243,6 +3307,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -3682,6 +3752,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3749,6 +3820,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -3837,6 +3914,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3904,6 +3982,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -4335,6 +4419,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4402,6 +4487,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -4490,6 +4581,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4557,6 +4649,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs index 896a52e93..4dbc74e11 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs @@ -406,6 +406,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -473,6 +474,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -557,6 +564,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -624,6 +632,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -1030,6 +1044,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1097,6 +1112,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1174,6 +1195,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1241,6 +1263,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -1714,6 +1742,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1781,6 +1810,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -1865,6 +1900,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1932,6 +1968,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -2351,6 +2393,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2418,6 +2461,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -2502,6 +2551,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2569,6 +2619,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -2982,6 +3038,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3049,6 +3106,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -3126,6 +3189,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3193,6 +3257,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -3675,6 +3745,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3742,6 +3813,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -3826,6 +3903,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3893,6 +3971,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], @@ -4306,6 +4390,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4373,6 +4458,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -4457,6 +4548,7 @@ public void CopyConstructor_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4524,6 +4616,12 @@ public void CopyConstructor_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], diff --git a/src/Orb.Tests/Services/PlanServiceTest.cs b/src/Orb.Tests/Services/PlanServiceTest.cs index 8df29ba72..6277e0030 100644 --- a/src/Orb.Tests/Services/PlanServiceTest.cs +++ b/src/Orb.Tests/Services/PlanServiceTest.cs @@ -39,6 +39,7 @@ public async Task Create_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, PlanPhaseOrder = 0, @@ -79,6 +80,7 @@ public async Task Create_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, diff --git a/src/Orb.Tests/Services/PriceServiceTest.cs b/src/Orb.Tests/Services/PriceServiceTest.cs index bf53a364a..2a4a7c553 100644 --- a/src/Orb.Tests/Services/PriceServiceTest.cs +++ b/src/Orb.Tests/Services/PriceServiceTest.cs @@ -48,6 +48,7 @@ public async Task Create_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, }, diff --git a/src/Orb/Models/Allocation.cs b/src/Orb/Models/Allocation.cs index c00a30546..c4b33b4db 100644 --- a/src/Orb/Models/Allocation.cs +++ b/src/Orb/Models/Allocation.cs @@ -64,6 +64,16 @@ public IReadOnlyList? Filters } } + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// public override void Validate() { @@ -74,6 +84,7 @@ public override void Validate() { item.Validate(); } + _ = this.LicenseTypeID; } public Allocation() { } diff --git a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs index 9eceac571..bc143cc1f 100644 --- a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs @@ -1443,6 +1443,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -3796,6 +3836,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -3858,6 +3911,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4720,6 +4774,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4782,6 +4849,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5576,6 +5644,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5638,6 +5719,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6381,6 +6463,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6443,6 +6538,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7180,6 +7276,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7237,6 +7346,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7924,6 +8034,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7986,6 +8109,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -9834,6 +9958,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -12276,6 +12440,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -12338,6 +12515,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -13268,6 +13446,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -13330,6 +13521,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -14153,6 +14345,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -14215,6 +14420,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -14979,6 +15185,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -15041,6 +15260,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -15802,6 +16022,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -15859,6 +16092,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -16568,6 +16802,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -16630,6 +16877,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index 847392b0b..ad8fd799e 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -1445,6 +1445,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -3798,6 +3838,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -3860,6 +3913,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4722,6 +4776,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4784,6 +4851,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5578,6 +5646,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5640,6 +5721,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6383,6 +6465,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6445,6 +6540,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7182,6 +7278,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7239,6 +7348,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7926,6 +8036,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7988,6 +8111,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -9836,6 +9960,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -12278,6 +12442,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -12340,6 +12517,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -13270,6 +13448,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -13332,6 +13523,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -14155,6 +14347,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -14217,6 +14422,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -14981,6 +15187,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -15043,6 +15262,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -15804,6 +16024,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -15861,6 +16094,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -16570,6 +16804,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -16632,6 +16879,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index d99c29d1f..f199ef27b 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -49,7 +49,8 @@ namespace Orb.Models.Customers.Credits.Ledger; /// body of this request, Orb will also generate a one-off invoice for the customer /// for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, /// since the total charges on the invoice are calculated by multiplying the cost -/// basis with the number of credit units added. +/// basis with the number of credit units added. Additionally, Orb also enforces +/// invoice generation when a non-zero `per_unit_cost_basis` value is provided. /// /// ## Deducting Credits Orb allows you to deduct credits from a customer by /// creating an entry of type `decrement`. Orb matches the algorithm for automatic diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index 9c3b7edf4..b27056180 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -49,7 +49,8 @@ namespace Orb.Models.Customers.Credits.Ledger; /// body of this request, Orb will also generate a one-off invoice for the customer /// for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, /// since the total charges on the invoice are calculated by multiplying the cost -/// basis with the number of credit units added. +/// basis with the number of credit units added. Additionally, Orb also enforces +/// invoice generation when a non-zero `per_unit_cost_basis` value is provided. /// /// ## Deducting Credits Orb allows you to deduct credits from a customer by /// creating an entry of type `decrement`. Orb matches the algorithm for automatic diff --git a/src/Orb/Models/NewAllocationPrice.cs b/src/Orb/Models/NewAllocationPrice.cs index 24b7b3205..99e477d6f 100644 --- a/src/Orb/Models/NewAllocationPrice.cs +++ b/src/Orb/Models/NewAllocationPrice.cs @@ -116,6 +116,19 @@ public string? ItemID init { this._rawData.Set("item_id", value); } } + /// + /// The license type ID to associate the price with license allocation. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// The (per-unit) cost basis of each created block. If non-zero, a customer /// will be invoiced according to the quantity and per unit cost basis specified @@ -152,6 +165,7 @@ public override void Validate() item.Validate(); } _ = this.ItemID; + _ = this.LicenseTypeID; _ = this.PerUnitCostBasis; } diff --git a/src/Orb/Models/NewFloatingBulkPrice.cs b/src/Orb/Models/NewFloatingBulkPrice.cs index 3fb0f55ea..f034a5d69 100644 --- a/src/Orb/Models/NewFloatingBulkPrice.cs +++ b/src/Orb/Models/NewFloatingBulkPrice.cs @@ -231,6 +231,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -271,6 +284,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs index 2fb16a788..83c922c42 100644 --- a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs index 09f914877..573b41a9c 100644 --- a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs index 9e4c7d68b..622ae6ca4 100644 --- a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs @@ -242,6 +242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -282,6 +295,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs index 6538621c6..2407ac8a2 100644 --- a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs index 581f2dfe8..efdeb94d4 100644 --- a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs @@ -238,6 +238,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -278,6 +291,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs index 18322d410..5e3bcd140 100644 --- a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs index 17138f55c..45eee68e7 100644 --- a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs @@ -242,6 +242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -282,6 +295,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingMatrixPrice.cs b/src/Orb/Models/NewFloatingMatrixPrice.cs index ad89afcc8..8812a9bd8 100644 --- a/src/Orb/Models/NewFloatingMatrixPrice.cs +++ b/src/Orb/Models/NewFloatingMatrixPrice.cs @@ -235,6 +235,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -275,6 +288,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs index fec00e68c..684e77d27 100644 --- a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs @@ -242,6 +242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -282,6 +295,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs index 81c0c40f6..9310d2ff6 100644 --- a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs index c081363d2..ce3829815 100644 --- a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs index 6bb7346c7..eb62b0d52 100644 --- a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs +++ b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs @@ -242,6 +242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -282,6 +295,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingPackagePrice.cs b/src/Orb/Models/NewFloatingPackagePrice.cs index 00cab9673..91b6d0c83 100644 --- a/src/Orb/Models/NewFloatingPackagePrice.cs +++ b/src/Orb/Models/NewFloatingPackagePrice.cs @@ -235,6 +235,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -275,6 +288,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs index 9339113d6..1a292a3cd 100644 --- a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs @@ -242,6 +242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -282,6 +295,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs index cf85e7470..3eff528fe 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs @@ -246,6 +246,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -286,6 +299,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs index b1343071b..7ce662598 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs @@ -246,6 +246,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -286,6 +299,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs index e94980fad..dbc4b7e62 100644 --- a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingTieredPackagePrice.cs b/src/Orb/Models/NewFloatingTieredPackagePrice.cs index 9c6656ef8..fc3b001b2 100644 --- a/src/Orb/Models/NewFloatingTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingTieredPackagePrice.cs @@ -238,6 +238,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -278,6 +291,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs index f75c6b836..be8baccef 100644 --- a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingTieredPrice.cs b/src/Orb/Models/NewFloatingTieredPrice.cs index ce6141aa9..e2461de80 100644 --- a/src/Orb/Models/NewFloatingTieredPrice.cs +++ b/src/Orb/Models/NewFloatingTieredPrice.cs @@ -235,6 +235,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -275,6 +288,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs index 8ddd4ab0f..35cbcb328 100644 --- a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs index 3c0a5c86b..c7b4faead 100644 --- a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -283,6 +296,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingUnitPrice.cs b/src/Orb/Models/NewFloatingUnitPrice.cs index 8e3d309e2..d31769474 100644 --- a/src/Orb/Models/NewFloatingUnitPrice.cs +++ b/src/Orb/Models/NewFloatingUnitPrice.cs @@ -235,6 +235,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -275,6 +288,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs index 6df010868..2c95991cd 100644 --- a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs +++ b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs @@ -240,6 +240,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -280,6 +293,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs index cbdcd33d1..8c7fe21e9 100644 --- a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs @@ -242,6 +242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -282,6 +295,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/NewPlanBulkPrice.cs b/src/Orb/Models/NewPlanBulkPrice.cs index 83801bf31..6a0a980a1 100644 --- a/src/Orb/Models/NewPlanBulkPrice.cs +++ b/src/Orb/Models/NewPlanBulkPrice.cs @@ -236,6 +236,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -290,6 +303,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs index dda98ba1c..999911571 100644 --- a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs +++ b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs @@ -241,6 +241,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -295,6 +308,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs index 2f0814789..96133fa2d 100644 --- a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs index 0b487609f..767228762 100644 --- a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs +++ b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs @@ -240,6 +240,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -294,6 +307,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs index 75c4dccda..c772bf2a3 100644 --- a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanGroupedTieredPrice.cs b/src/Orb/Models/NewPlanGroupedTieredPrice.cs index 5a4d96d89..30bee9235 100644 --- a/src/Orb/Models/NewPlanGroupedTieredPrice.cs +++ b/src/Orb/Models/NewPlanGroupedTieredPrice.cs @@ -241,6 +241,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -295,6 +308,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs index 7320e9039..04a942e4e 100644 --- a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs index 9306527c0..31d982092 100644 --- a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -297,6 +310,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanMatrixPrice.cs b/src/Orb/Models/NewPlanMatrixPrice.cs index f962b83b7..d64d9252b 100644 --- a/src/Orb/Models/NewPlanMatrixPrice.cs +++ b/src/Orb/Models/NewPlanMatrixPrice.cs @@ -236,6 +236,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -290,6 +303,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs index d3eea5a9a..34301621a 100644 --- a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -297,6 +310,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs index 794b66f64..cc880fdab 100644 --- a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs index b3e70bd5a..ae0bd1cd2 100644 --- a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanMinimumCompositePrice.cs b/src/Orb/Models/NewPlanMinimumCompositePrice.cs index b20cf96a8..a8d253b8f 100644 --- a/src/Orb/Models/NewPlanMinimumCompositePrice.cs +++ b/src/Orb/Models/NewPlanMinimumCompositePrice.cs @@ -240,6 +240,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -294,6 +307,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanPackagePrice.cs b/src/Orb/Models/NewPlanPackagePrice.cs index 1b9ce322c..2f284fde9 100644 --- a/src/Orb/Models/NewPlanPackagePrice.cs +++ b/src/Orb/Models/NewPlanPackagePrice.cs @@ -236,6 +236,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -290,6 +303,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs index 8337aa005..df7cd6be2 100644 --- a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs +++ b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -297,6 +310,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs index d9f46e354..3348e8422 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs index fd83a553f..39032666a 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs index 9a9a8c5da..1ec898586 100644 --- a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanTieredPackagePrice.cs b/src/Orb/Models/NewPlanTieredPackagePrice.cs index 3aa306b95..704fd8a62 100644 --- a/src/Orb/Models/NewPlanTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanTieredPackagePrice.cs @@ -241,6 +241,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -295,6 +308,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs index 2009b73a8..85ed66581 100644 --- a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanTieredPrice.cs b/src/Orb/Models/NewPlanTieredPrice.cs index b1ec2f26b..23e81bb16 100644 --- a/src/Orb/Models/NewPlanTieredPrice.cs +++ b/src/Orb/Models/NewPlanTieredPrice.cs @@ -236,6 +236,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -290,6 +303,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs index cda64d35f..5150e160d 100644 --- a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs +++ b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs @@ -241,6 +241,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -295,6 +308,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanUnitPrice.cs b/src/Orb/Models/NewPlanUnitPrice.cs index f0a3b5c23..2413c718f 100644 --- a/src/Orb/Models/NewPlanUnitPrice.cs +++ b/src/Orb/Models/NewPlanUnitPrice.cs @@ -236,6 +236,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -290,6 +303,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs index 02da87f8a..a40dbc60b 100644 --- a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs +++ b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs @@ -240,6 +240,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -294,6 +307,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs index cc6b0df67..6908028b4 100644 --- a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs +++ b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs @@ -240,6 +240,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -294,6 +307,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Plans/PlanCreateParams.cs b/src/Orb/Models/Plans/PlanCreateParams.cs index 84a1e3e07..c65baa4c9 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -883,6 +883,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -3251,6 +3291,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -3313,6 +3366,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4175,6 +4229,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4237,6 +4304,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5031,6 +5099,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5093,6 +5174,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5836,6 +5918,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5898,6 +5993,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6635,6 +6731,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6692,6 +6801,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7379,6 +7489,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7441,6 +7564,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index 1d91e84f2..144137313 100644 --- a/src/Orb/Models/Price.cs +++ b/src/Orb/Models/Price.cs @@ -3223,6 +3223,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public LicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -3260,6 +3275,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -3956,6 +3972,97 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public LicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseType(LicenseType licenseType) + : base(licenseType) { } +#pragma warning restore CS8618 + + public LicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseType FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeFromRaw : IFromRawJson +{ + /// + public LicenseType FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class Tiered : JsonModel { @@ -4287,6 +4394,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public TieredLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -4324,6 +4446,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -5024,6 +5147,99 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public TieredLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredLicenseType(TieredLicenseType tieredLicenseType) + : base(tieredLicenseType) { } +#pragma warning restore CS8618 + + public TieredLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredLicenseTypeFromRaw : IFromRawJson +{ + /// + public TieredLicenseType FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class Bulk : JsonModel { @@ -5353,6 +5569,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public BulkLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -5390,6 +5621,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -6089,6 +6321,97 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public BulkLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkLicenseType(BulkLicenseType bulkLicenseType) + : base(bulkLicenseType) { } +#pragma warning restore CS8618 + + public BulkLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkLicenseType FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkLicenseTypeFromRaw : IFromRawJson +{ + /// + public BulkLicenseType FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFilters : JsonModel { @@ -6424,6 +6747,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public BulkWithFiltersLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -6466,6 +6804,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -7436,6 +7775,102 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class BulkWithFiltersLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public BulkWithFiltersLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersLicenseType(BulkWithFiltersLicenseType bulkWithFiltersLicenseType) + : base(bulkWithFiltersLicenseType) { } +#pragma warning restore CS8618 + + public BulkWithFiltersLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithFiltersLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithFiltersLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithFiltersLicenseTypeFromRaw : IFromRawJson +{ + /// + public BulkWithFiltersLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithFiltersLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class Package : JsonModel { @@ -7767,6 +8202,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public PackageLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -7804,6 +8254,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -8504,6 +8955,99 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PackageLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public PackageLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageLicenseType(PackageLicenseType packageLicenseType) + : base(packageLicenseType) { } +#pragma warning restore CS8618 + + public PackageLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageLicenseTypeFromRaw : IFromRawJson +{ + /// + public PackageLicenseType FromRawUnchecked(IReadOnlyDictionary rawData) => + PackageLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class Matrix : JsonModel { @@ -8835,6 +9379,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public MatrixLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -8872,6 +9431,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -9572,6 +10132,99 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public MatrixLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixLicenseType(MatrixLicenseType matrixLicenseType) + : base(matrixLicenseType) { } +#pragma warning restore CS8618 + + public MatrixLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixLicenseTypeFromRaw : IFromRawJson +{ + /// + public MatrixLicenseType FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class ThresholdTotalAmount : JsonModel { @@ -9909,6 +10562,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public ThresholdTotalAmountLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -9951,6 +10619,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ThresholdTotalAmountConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -10858,6 +11527,107 @@ IReadOnlyDictionary rawData ) => ThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + ThresholdTotalAmountLicenseType, + ThresholdTotalAmountLicenseTypeFromRaw + >) +)] +public sealed record class ThresholdTotalAmountLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public ThresholdTotalAmountLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmountLicenseType( + ThresholdTotalAmountLicenseType thresholdTotalAmountLicenseType + ) + : base(thresholdTotalAmountLicenseType) { } +#pragma warning restore CS8618 + + public ThresholdTotalAmountLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdTotalAmountLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdTotalAmountLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThresholdTotalAmountLicenseTypeFromRaw : IFromRawJson +{ + /// + public ThresholdTotalAmountLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmountLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredPackage : JsonModel { @@ -11193,6 +11963,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public TieredPackageLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -11235,6 +12020,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -12118,6 +12904,102 @@ IReadOnlyDictionary rawData ) => TieredPackageTieredPackageConfigTier.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredPackageLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public TieredPackageLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageLicenseType(TieredPackageLicenseType tieredPackageLicenseType) + : base(tieredPackageLicenseType) { } +#pragma warning restore CS8618 + + public TieredPackageLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageLicenseTypeFromRaw : IFromRawJson +{ + /// + public TieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithMinimum : JsonModel { @@ -12455,6 +13337,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public TieredWithMinimumLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -12497,6 +13394,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -13439,6 +14337,102 @@ IReadOnlyDictionary rawData ) => TieredWithMinimumTieredWithMinimumConfigTier.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithMinimumLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public TieredWithMinimumLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumLicenseType(TieredWithMinimumLicenseType tieredWithMinimumLicenseType) + : base(tieredWithMinimumLicenseType) { } +#pragma warning restore CS8618 + + public TieredWithMinimumLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumLicenseTypeFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class GroupedTiered : JsonModel { @@ -13774,6 +14768,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public GroupedTieredLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -13816,6 +14825,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -14699,6 +15709,102 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedTieredLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedTieredLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredLicenseType(GroupedTieredLicenseType groupedTieredLicenseType) + : base(groupedTieredLicenseType) { } +#pragma warning restore CS8618 + + public GroupedTieredLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredLicenseTypeFromRaw : IFromRawJson +{ + /// + public GroupedTieredLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -15038,6 +16144,23 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public TieredPackageWithMinimumLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_type" + ); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -15080,6 +16203,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -15987,6 +17111,107 @@ IReadOnlyDictionary rawData ) => TieredPackageWithMinimumTieredPackageWithMinimumConfigTier.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumLicenseType, + TieredPackageWithMinimumLicenseTypeFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public TieredPackageWithMinimumLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumLicenseType( + TieredPackageWithMinimumLicenseType tieredPackageWithMinimumLicenseType + ) + : base(tieredPackageWithMinimumLicenseType) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumLicenseTypeFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class PackageWithAllocation : JsonModel { @@ -16324,6 +17549,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public PackageWithAllocationLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -16366,6 +17606,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -17171,6 +18412,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + PackageWithAllocationLicenseType, + PackageWithAllocationLicenseTypeFromRaw + >) +)] +public sealed record class PackageWithAllocationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public PackageWithAllocationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocationLicenseType( + PackageWithAllocationLicenseType packageWithAllocationLicenseType + ) + : base(packageWithAllocationLicenseType) { } +#pragma warning restore CS8618 + + public PackageWithAllocationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationLicenseTypeFromRaw : IFromRawJson +{ + /// + public PackageWithAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class UnitWithPercent : JsonModel { @@ -17508,6 +18850,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public UnitWithPercentLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -17550,6 +18907,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithPercentConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -18341,6 +19699,102 @@ IReadOnlyDictionary rawData ) => UnitWithPercentUnitWithPercentConfig.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UnitWithPercentLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public UnitWithPercentLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercentLicenseType(UnitWithPercentLicenseType unitWithPercentLicenseType) + : base(unitWithPercentLicenseType) { } +#pragma warning restore CS8618 + + public UnitWithPercentLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercentLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercentLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentLicenseTypeFromRaw : IFromRawJson +{ + /// + public UnitWithPercentLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithPercentLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class MatrixWithAllocation : JsonModel { @@ -18678,6 +20132,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public MatrixWithAllocationLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -18720,6 +20189,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -19433,6 +20903,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithAllocationLicenseType, + MatrixWithAllocationLicenseTypeFromRaw + >) +)] +public sealed record class MatrixWithAllocationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public MatrixWithAllocationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithAllocationLicenseType( + MatrixWithAllocationLicenseType matrixWithAllocationLicenseType + ) + : base(matrixWithAllocationLicenseType) { } +#pragma warning restore CS8618 + + public MatrixWithAllocationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithAllocationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithAllocationLicenseTypeFromRaw : IFromRawJson +{ + /// + public MatrixWithAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithAllocationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithProration : JsonModel { @@ -19770,6 +21341,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public TieredWithProrationLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -19812,6 +21398,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -20702,6 +22289,107 @@ IReadOnlyDictionary rawData ) => TieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredWithProrationLicenseType, + TieredWithProrationLicenseTypeFromRaw + >) +)] +public sealed record class TieredWithProrationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public TieredWithProrationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationLicenseType( + TieredWithProrationLicenseType tieredWithProrationLicenseType + ) + : base(tieredWithProrationLicenseType) { } +#pragma warning restore CS8618 + + public TieredWithProrationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationLicenseTypeFromRaw : IFromRawJson +{ + /// + public TieredWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class UnitWithProration : JsonModel { @@ -21039,6 +22727,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public UnitWithProrationLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -21081,6 +22784,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -21870,6 +23574,102 @@ IReadOnlyDictionary rawData ) => UnitWithProrationUnitWithProrationConfig.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UnitWithProrationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public UnitWithProrationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationLicenseType(UnitWithProrationLicenseType unitWithProrationLicenseType) + : base(unitWithProrationLicenseType) { } +#pragma warning restore CS8618 + + public UnitWithProrationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithProrationLicenseTypeFromRaw : IFromRawJson +{ + /// + public UnitWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithProrationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class GroupedAllocation : JsonModel { @@ -22207,6 +24007,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public GroupedAllocationLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -22249,6 +24064,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -23059,6 +24875,102 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedAllocationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedAllocationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationLicenseType(GroupedAllocationLicenseType groupedAllocationLicenseType) + : base(groupedAllocationLicenseType) { } +#pragma warning restore CS8618 + + public GroupedAllocationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationLicenseTypeFromRaw : IFromRawJson +{ + /// + public GroupedAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithProration : JsonModel { @@ -23396,6 +25308,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public BulkWithProrationLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -23438,6 +25365,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -24334,6 +26262,102 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class BulkWithProrationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public BulkWithProrationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationLicenseType(BulkWithProrationLicenseType bulkWithProrationLicenseType) + : base(bulkWithProrationLicenseType) { } +#pragma warning restore CS8618 + + public BulkWithProrationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationLicenseTypeFromRaw : IFromRawJson +{ + /// + public BulkWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -24673,6 +26697,23 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public GroupedWithProratedMinimumLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_type" + ); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -24715,6 +26756,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -25534,6 +27576,108 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumLicenseType, + GroupedWithProratedMinimumLicenseTypeFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedWithProratedMinimumLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumLicenseType( + GroupedWithProratedMinimumLicenseType groupedWithProratedMinimumLicenseType + ) + : base(groupedWithProratedMinimumLicenseType) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumLicenseTypeFromRaw + : IFromRawJson +{ + /// + public GroupedWithProratedMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -25873,6 +28017,23 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public GroupedWithMeteredMinimumLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_type" + ); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -25915,6 +28076,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -26975,6 +29137,108 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumLicenseType, + GroupedWithMeteredMinimumLicenseTypeFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedWithMeteredMinimumLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumLicenseType( + GroupedWithMeteredMinimumLicenseType groupedWithMeteredMinimumLicenseType + ) + : base(groupedWithMeteredMinimumLicenseType) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumLicenseTypeFromRaw + : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimumLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -27314,6 +29578,23 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public GroupedWithMinMaxThresholdsLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_type" + ); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -27356,6 +29637,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -28187,6 +30469,108 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMinMaxThresholdsLicenseType, + GroupedWithMinMaxThresholdsLicenseTypeFromRaw + >) +)] +public sealed record class GroupedWithMinMaxThresholdsLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedWithMinMaxThresholdsLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsLicenseType( + GroupedWithMinMaxThresholdsLicenseType groupedWithMinMaxThresholdsLicenseType + ) + : base(groupedWithMinMaxThresholdsLicenseType) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholdsLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMinMaxThresholdsLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMinMaxThresholdsLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMinMaxThresholdsLicenseTypeFromRaw + : IFromRawJson +{ + /// + public GroupedWithMinMaxThresholdsLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMinMaxThresholdsLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class MatrixWithDisplayName : JsonModel { @@ -28524,6 +30908,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public MatrixWithDisplayNameLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -28566,6 +30965,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -29479,6 +31879,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameLicenseType, + MatrixWithDisplayNameLicenseTypeFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public MatrixWithDisplayNameLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameLicenseType( + MatrixWithDisplayNameLicenseType matrixWithDisplayNameLicenseType + ) + : base(matrixWithDisplayNameLicenseType) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameLicenseTypeFromRaw : IFromRawJson +{ + /// + public MatrixWithDisplayNameLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class GroupedTieredPackage : JsonModel { @@ -29816,6 +32317,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public GroupedTieredPackageLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -29858,6 +32374,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -30767,6 +33284,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredPackageLicenseType, + GroupedTieredPackageLicenseTypeFromRaw + >) +)] +public sealed record class GroupedTieredPackageLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedTieredPackageLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageLicenseType( + GroupedTieredPackageLicenseType groupedTieredPackageLicenseType + ) + : base(groupedTieredPackageLicenseType) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageLicenseTypeFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class MaxGroupTieredPackage : JsonModel { @@ -31104,6 +33722,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public MaxGroupTieredPackageLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -31146,6 +33779,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -32054,6 +34688,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + MaxGroupTieredPackageLicenseType, + MaxGroupTieredPackageLicenseTypeFromRaw + >) +)] +public sealed record class MaxGroupTieredPackageLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public MaxGroupTieredPackageLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageLicenseType( + MaxGroupTieredPackageLicenseType maxGroupTieredPackageLicenseType + ) + : base(maxGroupTieredPackageLicenseType) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageLicenseTypeFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -32393,6 +35128,23 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public ScalableMatrixWithUnitPricingLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_type" + ); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -32435,6 +35187,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ScalableMatrixWithUnitPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -33398,6 +36151,110 @@ IReadOnlyDictionary rawData ); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithUnitPricingLicenseType, + ScalableMatrixWithUnitPricingLicenseTypeFromRaw + >) +)] +public sealed record class ScalableMatrixWithUnitPricingLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public ScalableMatrixWithUnitPricingLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingLicenseType( + ScalableMatrixWithUnitPricingLicenseType scalableMatrixWithUnitPricingLicenseType + ) + : base(scalableMatrixWithUnitPricingLicenseType) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricingLicenseType( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricingLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricingLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingLicenseTypeFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricingLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricingLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter< ScalableMatrixWithTieredPricing, @@ -33740,6 +36597,23 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public ScalableMatrixWithTieredPricingLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_type" + ); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -33782,6 +36656,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ScalableMatrixWithTieredPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -34832,6 +37707,110 @@ IReadOnlyDictionary rawData ); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingLicenseType, + ScalableMatrixWithTieredPricingLicenseTypeFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public ScalableMatrixWithTieredPricingLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingLicenseType( + ScalableMatrixWithTieredPricingLicenseType scalableMatrixWithTieredPricingLicenseType + ) + : base(scalableMatrixWithTieredPricingLicenseType) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingLicenseType( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingLicenseTypeFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class CumulativeGroupedBulk : JsonModel { @@ -35169,6 +38148,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public CumulativeGroupedBulkLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -35211,6 +38205,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -36122,6 +39117,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedBulkLicenseType, + CumulativeGroupedBulkLicenseTypeFromRaw + >) +)] +public sealed record class CumulativeGroupedBulkLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public CumulativeGroupedBulkLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkLicenseType( + CumulativeGroupedBulkLicenseType cumulativeGroupedBulkLicenseType + ) + : base(cumulativeGroupedBulkLicenseType) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulkLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkLicenseTypeFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedBulkLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -36461,6 +39557,23 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public CumulativeGroupedAllocationLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_type" + ); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -36503,6 +39616,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -37334,6 +40448,108 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationLicenseType, + CumulativeGroupedAllocationLicenseTypeFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public CumulativeGroupedAllocationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationLicenseType( + CumulativeGroupedAllocationLicenseType cumulativeGroupedAllocationLicenseType + ) + : base(cumulativeGroupedAllocationLicenseType) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationLicenseTypeFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class MinimumComposite : JsonModel { @@ -37671,6 +40887,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public MinimumCompositeLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -37713,6 +40944,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -38522,6 +41754,102 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class MinimumCompositeLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public MinimumCompositeLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumCompositeLicenseType(MinimumCompositeLicenseType minimumCompositeLicenseType) + : base(minimumCompositeLicenseType) { } +#pragma warning restore CS8618 + + public MinimumCompositeLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumCompositeLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumCompositeLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MinimumCompositeLicenseTypeFromRaw : IFromRawJson +{ + /// + public MinimumCompositeLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MinimumCompositeLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class Percent : JsonModel { @@ -38853,6 +42181,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public PercentLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -38890,6 +42233,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -39657,6 +43001,99 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public PercentLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentLicenseType(PercentLicenseType percentLicenseType) + : base(percentLicenseType) { } +#pragma warning restore CS8618 + + public PercentLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PercentLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PercentLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PercentLicenseTypeFromRaw : IFromRawJson +{ + /// + public PercentLicenseType FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutput : JsonModel { @@ -39990,6 +43427,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public EventOutputLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -40032,6 +43484,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -40837,3 +44290,97 @@ JsonSerializerOptions options ); } } + +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public EventOutputLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputLicenseType(EventOutputLicenseType eventOutputLicenseType) + : base(eventOutputLicenseType) { } +#pragma warning restore CS8618 + + public EventOutputLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + EventOutputLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static EventOutputLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class EventOutputLicenseTypeFromRaw : IFromRawJson +{ + /// + public EventOutputLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => EventOutputLicenseType.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Prices/PriceCreateParams.cs b/src/Orb/Models/Prices/PriceCreateParams.cs index 69bcaa228..a68943402 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -657,6 +657,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newFloatingUnitPrice: (x) => x.LicenseTypeID, + newFloatingTieredPrice: (x) => x.LicenseTypeID, + newFloatingBulkPrice: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newFloatingPackagePrice: (x) => x.LicenseTypeID, + newFloatingMatrixPrice: (x) => x.LicenseTypeID, + newFloatingThresholdTotalAmountPrice: (x) => x.LicenseTypeID, + newFloatingTieredPackagePrice: (x) => x.LicenseTypeID, + newFloatingTieredWithMinimumPrice: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPrice: (x) => x.LicenseTypeID, + newFloatingTieredPackageWithMinimumPrice: (x) => x.LicenseTypeID, + newFloatingPackageWithAllocationPrice: (x) => x.LicenseTypeID, + newFloatingUnitWithPercentPrice: (x) => x.LicenseTypeID, + newFloatingMatrixWithAllocationPrice: (x) => x.LicenseTypeID, + newFloatingTieredWithProrationPrice: (x) => x.LicenseTypeID, + newFloatingUnitWithProrationPrice: (x) => x.LicenseTypeID, + newFloatingGroupedAllocationPrice: (x) => x.LicenseTypeID, + newFloatingBulkWithProrationPrice: (x) => x.LicenseTypeID, + newFloatingGroupedWithProratedMinimumPrice: (x) => x.LicenseTypeID, + newFloatingGroupedWithMeteredMinimumPrice: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newFloatingMatrixWithDisplayNamePrice: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPackagePrice: (x) => x.LicenseTypeID, + newFloatingMaxGroupTieredPackagePrice: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithUnitPricingPrice: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.LicenseTypeID, + newFloatingCumulativeGroupedBulkPrice: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingMinimumCompositePrice: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public Body(NewFloatingUnitPrice value, JsonElement? element = null) { this.Value = value; @@ -3027,6 +3067,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -3075,6 +3128,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3937,6 +3991,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -3985,6 +4052,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4726,6 +4794,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4774,6 +4855,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5509,6 +5591,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5552,6 +5647,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6237,6 +6333,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6285,6 +6394,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs index 694aab906..ffc95c951 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -861,6 +861,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newFloatingUnit: (x) => x.LicenseTypeID, + newFloatingTiered: (x) => x.LicenseTypeID, + newFloatingBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newFloatingPackage: (x) => x.LicenseTypeID, + newFloatingMatrix: (x) => x.LicenseTypeID, + newFloatingThresholdTotalAmount: (x) => x.LicenseTypeID, + newFloatingTieredPackage: (x) => x.LicenseTypeID, + newFloatingTieredWithMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedTiered: (x) => x.LicenseTypeID, + newFloatingTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newFloatingPackageWithAllocation: (x) => x.LicenseTypeID, + newFloatingUnitWithPercent: (x) => x.LicenseTypeID, + newFloatingMatrixWithAllocation: (x) => x.LicenseTypeID, + newFloatingTieredWithProration: (x) => x.LicenseTypeID, + newFloatingUnitWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingBulkWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newFloatingMatrixWithDisplayName: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPackage: (x) => x.LicenseTypeID, + newFloatingMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newFloatingCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public Price(NewFloatingUnitPrice value, JsonElement? element = null) { this.Value = value; @@ -3210,6 +3250,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -3258,6 +3311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4179,6 +4233,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4227,6 +4294,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4980,6 +5048,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5028,6 +5109,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5772,6 +5854,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5815,6 +5910,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6510,6 +6606,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6558,6 +6667,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs index 025872a13..4ab1cced3 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs @@ -1017,6 +1017,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newFloatingUnit: (x) => x.LicenseTypeID, + newFloatingTiered: (x) => x.LicenseTypeID, + newFloatingBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newFloatingPackage: (x) => x.LicenseTypeID, + newFloatingMatrix: (x) => x.LicenseTypeID, + newFloatingThresholdTotalAmount: (x) => x.LicenseTypeID, + newFloatingTieredPackage: (x) => x.LicenseTypeID, + newFloatingTieredWithMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedTiered: (x) => x.LicenseTypeID, + newFloatingTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newFloatingPackageWithAllocation: (x) => x.LicenseTypeID, + newFloatingUnitWithPercent: (x) => x.LicenseTypeID, + newFloatingMatrixWithAllocation: (x) => x.LicenseTypeID, + newFloatingTieredWithProration: (x) => x.LicenseTypeID, + newFloatingUnitWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingBulkWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newFloatingMatrixWithDisplayName: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPackage: (x) => x.LicenseTypeID, + newFloatingMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newFloatingCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( NewFloatingUnitPrice value, JsonElement? element = null @@ -3571,6 +3611,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -3619,6 +3672,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4608,6 +4662,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4656,6 +4723,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5455,6 +5523,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5503,6 +5584,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6298,6 +6380,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6341,6 +6436,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7091,6 +7187,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7139,6 +7248,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs index 85a976e12..a6445dd23 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs @@ -236,6 +236,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -290,6 +303,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs index 3577de603..52f2a0285 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs index 62ce894a9..258d48185 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs index dcdcfbb56..4edada7bf 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -297,6 +310,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs index b1c090704..d15a794a5 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs index cfa894bcd..c0b3f3184 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs @@ -242,6 +242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -296,6 +309,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs index 452dec270..3e441f5d2 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs @@ -247,6 +247,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -301,6 +314,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs index 44044b9ea..7cf45eab2 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs @@ -246,6 +246,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -300,6 +313,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs index 5248614bd..81bcdf606 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs @@ -238,6 +238,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -292,6 +305,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs index eabc8a54d..84a692050 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -297,6 +310,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs index 83a13ceb1..90d900c22 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs index dcfb0b500..b5b5960a3 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs index 4f8e93ebb..750f7e3ae 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -297,6 +310,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs index a2a712adb..8b8772c66 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs @@ -238,6 +238,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -292,6 +305,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs index 02cc7b2b2..43aa7b301 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -297,6 +310,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs index 5474b20b3..4848de524 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs @@ -250,6 +250,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -304,6 +317,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs index 4f02edef0..b8e36562f 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs @@ -250,6 +250,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -304,6 +317,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs index 722539fec..d0784335c 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs index 5ea2b4d74..19417c32b 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs @@ -242,6 +242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -296,6 +309,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs index 7c171af70..dcfe83272 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs index 8c6517413..7e6aae968 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs @@ -238,6 +238,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -292,6 +305,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs index 80ebf4dd6..38e4b192a 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs @@ -244,6 +244,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -298,6 +311,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs index beb0130a1..27c0ed88c 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs @@ -238,6 +238,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -292,6 +305,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs index 66ec5b681..3f1714a90 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs @@ -241,6 +241,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -295,6 +308,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs index 3bc175cd6..ae19ea8db 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs @@ -243,6 +243,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -297,6 +310,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs index a337294da..20b34bee4 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -2143,6 +2143,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newSubscriptionUnit: (x) => x.LicenseTypeID, + newSubscriptionTiered: (x) => x.LicenseTypeID, + newSubscriptionBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newSubscriptionPackage: (x) => x.LicenseTypeID, + newSubscriptionMatrix: (x) => x.LicenseTypeID, + newSubscriptionThresholdTotalAmount: (x) => x.LicenseTypeID, + newSubscriptionTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionTieredWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedTiered: (x) => x.LicenseTypeID, + newSubscriptionTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionPackageWithAllocation: (x) => x.LicenseTypeID, + newSubscriptionUnitWithPercent: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newSubscriptionUnitWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionBulkWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithDisplayName: (x) => x.LicenseTypeID, + newSubscriptionGroupedTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newSubscriptionCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -4584,6 +4624,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4646,6 +4699,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5508,6 +5562,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5570,6 +5637,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6364,6 +6432,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6426,6 +6507,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7169,6 +7251,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7231,6 +7326,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7968,6 +8064,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -8025,6 +8134,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -8712,6 +8822,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -8774,6 +8897,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -10723,6 +10847,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newSubscriptionUnit: (x) => x.LicenseTypeID, + newSubscriptionTiered: (x) => x.LicenseTypeID, + newSubscriptionBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newSubscriptionPackage: (x) => x.LicenseTypeID, + newSubscriptionMatrix: (x) => x.LicenseTypeID, + newSubscriptionThresholdTotalAmount: (x) => x.LicenseTypeID, + newSubscriptionTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionTieredWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedTiered: (x) => x.LicenseTypeID, + newSubscriptionTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionPackageWithAllocation: (x) => x.LicenseTypeID, + newSubscriptionUnitWithPercent: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newSubscriptionUnitWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionBulkWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithDisplayName: (x) => x.LicenseTypeID, + newSubscriptionGroupedTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newSubscriptionCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -13284,6 +13448,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -13346,6 +13523,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -14276,6 +14454,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -14338,6 +14529,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -15161,6 +15353,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -15223,6 +15428,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -15987,6 +16193,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -16049,6 +16268,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -16810,6 +17030,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -16867,6 +17100,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -17576,6 +17810,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -17638,6 +17885,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index ee856d048..c367b59b6 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -2288,6 +2288,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newFloatingUnit: (x) => x.LicenseTypeID, + newFloatingTiered: (x) => x.LicenseTypeID, + newFloatingBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newFloatingPackage: (x) => x.LicenseTypeID, + newFloatingMatrix: (x) => x.LicenseTypeID, + newFloatingThresholdTotalAmount: (x) => x.LicenseTypeID, + newFloatingTieredPackage: (x) => x.LicenseTypeID, + newFloatingTieredWithMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedTiered: (x) => x.LicenseTypeID, + newFloatingTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newFloatingPackageWithAllocation: (x) => x.LicenseTypeID, + newFloatingUnitWithPercent: (x) => x.LicenseTypeID, + newFloatingMatrixWithAllocation: (x) => x.LicenseTypeID, + newFloatingTieredWithProration: (x) => x.LicenseTypeID, + newFloatingUnitWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingBulkWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newFloatingMatrixWithDisplayName: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPackage: (x) => x.LicenseTypeID, + newFloatingMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newFloatingCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public PriceModel(NewFloatingUnitPrice value, JsonElement? element = null) { this.Value = value; @@ -4667,6 +4707,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4715,6 +4768,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5641,6 +5695,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5689,6 +5756,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6445,6 +6513,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6493,6 +6574,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7242,6 +7324,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7285,6 +7380,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7987,6 +8083,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -8035,6 +8144,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } diff --git a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs index 6000d8a6a..cb7893888 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -2147,6 +2147,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newSubscriptionUnit: (x) => x.LicenseTypeID, + newSubscriptionTiered: (x) => x.LicenseTypeID, + newSubscriptionBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newSubscriptionPackage: (x) => x.LicenseTypeID, + newSubscriptionMatrix: (x) => x.LicenseTypeID, + newSubscriptionThresholdTotalAmount: (x) => x.LicenseTypeID, + newSubscriptionTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionTieredWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedTiered: (x) => x.LicenseTypeID, + newSubscriptionTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionPackageWithAllocation: (x) => x.LicenseTypeID, + newSubscriptionUnitWithPercent: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newSubscriptionUnitWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionBulkWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithDisplayName: (x) => x.LicenseTypeID, + newSubscriptionGroupedTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newSubscriptionCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -4794,6 +4834,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -4856,6 +4909,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5844,6 +5898,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -5906,6 +5973,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6778,6 +6846,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -6840,6 +6921,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7641,6 +7723,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -7703,6 +7798,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -8500,6 +8596,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -8557,6 +8666,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -9302,6 +9412,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -9364,6 +9487,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -11449,6 +11573,46 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newSubscriptionUnit: (x) => x.LicenseTypeID, + newSubscriptionTiered: (x) => x.LicenseTypeID, + newSubscriptionBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newSubscriptionPackage: (x) => x.LicenseTypeID, + newSubscriptionMatrix: (x) => x.LicenseTypeID, + newSubscriptionThresholdTotalAmount: (x) => x.LicenseTypeID, + newSubscriptionTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionTieredWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedTiered: (x) => x.LicenseTypeID, + newSubscriptionTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionPackageWithAllocation: (x) => x.LicenseTypeID, + newSubscriptionUnitWithPercent: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newSubscriptionUnitWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionBulkWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithDisplayName: (x) => x.LicenseTypeID, + newSubscriptionGroupedTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newSubscriptionCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -14103,6 +14267,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -14165,6 +14342,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -15156,6 +15334,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -15218,6 +15409,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -16092,6 +16284,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -16154,6 +16359,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -16955,6 +17161,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -17017,6 +17236,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -17814,6 +18034,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -17871,6 +18104,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18626,6 +18860,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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 @@ -18688,6 +18935,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } diff --git a/src/Orb/Services/Customers/Credits/ILedgerService.cs b/src/Orb/Services/Customers/Credits/ILedgerService.cs index bc36776d6..e97ffac9f 100644 --- a/src/Orb/Services/Customers/Credits/ILedgerService.cs +++ b/src/Orb/Services/Customers/Credits/ILedgerService.cs @@ -147,7 +147,9 @@ Task List( /// in the body of this request, Orb will also generate a one-off invoice for /// the customer for the credits pre-purchase. Note that you _must_ provide the /// `per_unit_cost_basis`, since the total charges on the invoice are calculated - /// by multiplying the cost basis with the number of credit units added. + /// by multiplying the cost basis with the number of credit units added. Additionally, + /// Orb also enforces invoice generation when a non-zero `per_unit_cost_basis` + /// value is provided. /// /// ## Deducting Credits Orb allows you to deduct credits from a customer /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic @@ -245,7 +247,9 @@ Task CreateEntry( /// in the body of this request, Orb will also generate a one-off invoice for /// the customer for the credits pre-purchase. Note that you _must_ provide the /// `per_unit_cost_basis`, since the total charges on the invoice are calculated - /// by multiplying the cost basis with the number of credit units added. + /// by multiplying the cost basis with the number of credit units added. Additionally, + /// Orb also enforces invoice generation when a non-zero `per_unit_cost_basis` + /// value is provided. /// /// ## Deducting Credits Orb allows you to deduct credits from a customer /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic From ab0951f3e4a8d9334991eb1c4cb5ca6d43039f10 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:17:48 +0000 Subject: [PATCH 18/39] fix(client): improve behaviour for comma-delimited binary content in multipart requests --- src/Orb/Core/MultipartJsonElement.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Orb/Core/MultipartJsonElement.cs b/src/Orb/Core/MultipartJsonElement.cs index e676ca7c4..f16d3d504 100644 --- a/src/Orb/Core/MultipartJsonElement.cs +++ b/src/Orb/Core/MultipartJsonElement.cs @@ -139,7 +139,7 @@ public static MultipartFormDataContent Serialize( var multipartElement = MultipartJsonSerializer.SerializeToElement(value, options); void SerializeParts(string name, JsonElement element) { - HttpContent content; + HttpContent? content; string? fileName = null; switch (element.ValueKind) { @@ -188,17 +188,21 @@ void SerializeParts(string name, JsonElement element) default: throw new ArgumentOutOfRangeException(nameof(element)); } - if (name == "") - { - formDataContent.Add(content); - } - else if (fileName == null) - { - formDataContent.Add(content, name); - } - else + + if (content != null) { - formDataContent.Add(content, name, fileName); + if (name == "") + { + formDataContent.Add(content); + } + else if (fileName == null) + { + formDataContent.Add(content, name); + } + else + { + formDataContent.Add(content, name, fileName); + } } } SerializeParts("", multipartElement.Json); From b7e314a7c42e00836f1db7589a2bdc71c78995e6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 04:22:12 +0000 Subject: [PATCH 19/39] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index a77b80771..3a5a4c8eb 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-6aa83a816c15600a3d6d378d7804a345505c76726059c19369db4e7766a71cbd.yml -openapi_spec_hash: f283d730e5320f9595c3c0a5902f5cbb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-90b631890d57a96df99cc973fedfb48e6278b025dcb6262519eb064044d47efe.yml +openapi_spec_hash: b17b00ef11d479516d6f1e5a323aef28 config_hash: bcf82bddb691f6be773ac6cae8c03b9a From 0273d508b173a0b758832ff31ea2ce0cd0b6f5e5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:20:19 +0000 Subject: [PATCH 20/39] chore(internal): codegen related update --- .../Invoices/InvoiceListSummaryParamsTest.cs | 26 +++++++------------ .../Invoices/InvoiceListSummaryParams.cs | 14 +++------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs index 38f487e10..3e7dfd039 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Text.Json; using Orb.Core; using Orb.Exceptions; @@ -31,7 +30,7 @@ public void FieldRoundtrip_Works() InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, Limit = 1, - Status = [InvoiceListSummaryParamsStatus.Draft], + Status = InvoiceListSummaryParamsStatus.Draft, SubscriptionID = "subscription_id", }; @@ -53,10 +52,8 @@ public void FieldRoundtrip_Works() DateTimeOffset expectedInvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); bool expectedIsRecurring = true; long expectedLimit = 1; - List> expectedStatus = - [ - InvoiceListSummaryParamsStatus.Draft, - ]; + ApiEnum expectedStatus = + InvoiceListSummaryParamsStatus.Draft; string expectedSubscriptionID = "subscription_id"; Assert.Equal(expectedAmount, parameters.Amount); @@ -76,12 +73,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedInvoiceDateLte, parameters.InvoiceDateLte); Assert.Equal(expectedIsRecurring, parameters.IsRecurring); Assert.Equal(expectedLimit, parameters.Limit); - Assert.NotNull(parameters.Status); - Assert.Equal(expectedStatus.Count, parameters.Status.Count); - for (int i = 0; i < expectedStatus.Count; i++) - { - Assert.Equal(expectedStatus[i], parameters.Status[i]); - } + Assert.Equal(expectedStatus, parameters.Status); Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); } @@ -106,7 +98,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], + Status = InvoiceListSummaryParamsStatus.Draft, SubscriptionID = "subscription_id", }; @@ -135,7 +127,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], + Status = InvoiceListSummaryParamsStatus.Draft, SubscriptionID = "subscription_id", // Null should be interpreted as omitted for these properties @@ -276,7 +268,7 @@ public void Url_Works() InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, Limit = 1, - Status = [InvoiceListSummaryParamsStatus.Draft], + Status = InvoiceListSummaryParamsStatus.Draft, SubscriptionID = "subscription_id", }; @@ -284,7 +276,7 @@ public void Url_Works() Assert.Equal( new Uri( - "https://api.withorb.com/v1/invoices/summary?amount=amount&amount%5bgt%5d=amount%5bgt%5d&amount%5blt%5d=amount%5blt%5d&cursor=cursor&customer_id=customer_id&date_type=due_date&due_date=2019-12-27&due_date_window=due_date_window&due_date%5bgt%5d=2019-12-27&due_date%5blt%5d=2019-12-27&external_customer_id=external_customer_id&invoice_date%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&invoice_date%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&invoice_date%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&invoice_date%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&is_recurring=true&limit=1&status%5b%5d=draft&subscription_id=subscription_id" + "https://api.withorb.com/v1/invoices/summary?amount=amount&amount%5bgt%5d=amount%5bgt%5d&amount%5blt%5d=amount%5blt%5d&cursor=cursor&customer_id=customer_id&date_type=due_date&due_date=2019-12-27&due_date_window=due_date_window&due_date%5bgt%5d=2019-12-27&due_date%5blt%5d=2019-12-27&external_customer_id=external_customer_id&invoice_date%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&invoice_date%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&invoice_date%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&invoice_date%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&is_recurring=true&limit=1&status=draft&subscription_id=subscription_id" ), url ); @@ -312,7 +304,7 @@ public void CopyConstructor_Works() InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, Limit = 1, - Status = [InvoiceListSummaryParamsStatus.Draft], + Status = InvoiceListSummaryParamsStatus.Draft, SubscriptionID = "subscription_id", }; diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs index e62a3533c..128f14f52 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs @@ -1,6 +1,5 @@ using System.Collections.Frozen; using System.Collections.Generic; -using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Text.Json; @@ -231,21 +230,16 @@ public long? Limit } } - public IReadOnlyList>? Status + public ApiEnum? Status { get { this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableStruct< - ImmutableArray> - >("status"); - } - init - { - this._rawQueryData.Set - >?>("status", value == null ? null : ImmutableArray.ToImmutableArray(value)); + >("status"); } + init { this._rawQueryData.Set("status", value); } } public string? SubscriptionID From 50b2cb1b1e7ca97069802de357b08a09fc60f95c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 18:22:26 +0000 Subject: [PATCH 21/39] feat(api): api update --- .stats.yml | 4 +- .../CreditBlockRetrieveResponseTest.cs | 21 ++++++++ .../CreditListByExternalIDPageResponseTest.cs | 7 +++ .../CreditListByExternalIDParamsTest.cs | 50 ++++++++++++++++++- .../CreditListByExternalIDResponseTest.cs | 21 ++++++++ .../Credits/CreditListPageResponseTest.cs | 7 +++ .../Customers/Credits/CreditListParamsTest.cs | 50 ++++++++++++++++++- .../Credits/CreditListResponseTest.cs | 21 ++++++++ .../CreditBlockRetrieveResponse.cs | 23 +++++++++ .../Credits/CreditListByExternalIDParams.cs | 45 +++++++++++++++++ .../Credits/CreditListByExternalIDResponse.cs | 23 +++++++++ .../Customers/Credits/CreditListParams.cs | 45 +++++++++++++++++ .../Customers/Credits/CreditListResponse.cs | 23 +++++++++ src/Orb/Services/Customers/ICreditService.cs | 10 ++++ 14 files changed, 346 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3a5a4c8eb..67224ec77 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-90b631890d57a96df99cc973fedfb48e6278b025dcb6262519eb064044d47efe.yml -openapi_spec_hash: b17b00ef11d479516d6f1e5a323aef28 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c92fb451e13f157b3735f188acc8d57aa3adfbaac1683645e1ba4f432dd7a4f8.yml +openapi_spec_hash: dbcd87ecfbd3976eb3b99ec6f9fbc606 config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs b/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs index f074b2ee6..692e3f712 100644 --- a/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs @@ -28,6 +28,7 @@ public void FieldRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; @@ -46,6 +47,7 @@ public void FieldRoundtrip_Works() }, ]; double expectedMaximumInitialBalance = 0; + Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedPerUnitCostBasis = "per_unit_cost_basis"; ApiEnum expectedStatus = Status.Active; @@ -59,6 +61,13 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFilters[i], model.Filters[i]); } Assert.Equal(expectedMaximumInitialBalance, model.MaximumInitialBalance); + 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(expectedPerUnitCostBasis, model.PerUnitCostBasis); Assert.Equal(expectedStatus, model.Status); } @@ -82,6 +91,7 @@ public void SerializationRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; @@ -114,6 +124,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; @@ -139,6 +150,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; double expectedMaximumInitialBalance = 0; + Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedPerUnitCostBasis = "per_unit_cost_basis"; ApiEnum expectedStatus = Status.Active; @@ -152,6 +164,13 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFilters[i], deserialized.Filters[i]); } Assert.Equal(expectedMaximumInitialBalance, deserialized.MaximumInitialBalance); + 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(expectedPerUnitCostBasis, deserialized.PerUnitCostBasis); Assert.Equal(expectedStatus, deserialized.Status); } @@ -175,6 +194,7 @@ public void Validation_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; @@ -201,6 +221,7 @@ public void CopyConstructor_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDPageResponseTest.cs index 74934f36f..09031d6de 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDPageResponseTest.cs @@ -32,6 +32,7 @@ public void FieldRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }, @@ -57,6 +58,7 @@ public void FieldRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }, @@ -98,6 +100,7 @@ public void SerializationRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }, @@ -137,6 +140,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }, @@ -169,6 +173,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }, @@ -210,6 +215,7 @@ public void Validation_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }, @@ -243,6 +249,7 @@ public void CopyConstructor_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }, diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs index 7d5128620..3c3407d05 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs @@ -13,6 +13,10 @@ public void FieldRoundtrip_Works() ExternalCustomerID = "external_customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IncludeAllBlocks = true, Limit = 1, }; @@ -20,12 +24,20 @@ public void FieldRoundtrip_Works() string expectedExternalCustomerID = "external_customer_id"; string expectedCurrency = "currency"; string expectedCursor = "cursor"; + DateTimeOffset expectedEffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedEffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedEffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedEffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); bool expectedIncludeAllBlocks = true; long expectedLimit = 1; Assert.Equal(expectedExternalCustomerID, parameters.ExternalCustomerID); Assert.Equal(expectedCurrency, parameters.Currency); Assert.Equal(expectedCursor, parameters.Cursor); + Assert.Equal(expectedEffectiveDateGt, parameters.EffectiveDateGt); + Assert.Equal(expectedEffectiveDateGte, parameters.EffectiveDateGte); + Assert.Equal(expectedEffectiveDateLt, parameters.EffectiveDateLt); + Assert.Equal(expectedEffectiveDateLte, parameters.EffectiveDateLte); Assert.Equal(expectedIncludeAllBlocks, parameters.IncludeAllBlocks); Assert.Equal(expectedLimit, parameters.Limit); } @@ -38,6 +50,10 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() ExternalCustomerID = "external_customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; Assert.Null(parameters.IncludeAllBlocks); @@ -54,6 +70,10 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() ExternalCustomerID = "external_customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), // Null should be interpreted as omitted for these properties IncludeAllBlocks = null, @@ -80,6 +100,14 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Assert.False(parameters.RawQueryData.ContainsKey("currency")); Assert.Null(parameters.Cursor); Assert.False(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EffectiveDateGt); + Assert.False(parameters.RawQueryData.ContainsKey("effective_date[gt]")); + Assert.Null(parameters.EffectiveDateGte); + Assert.False(parameters.RawQueryData.ContainsKey("effective_date[gte]")); + Assert.Null(parameters.EffectiveDateLt); + Assert.False(parameters.RawQueryData.ContainsKey("effective_date[lt]")); + Assert.Null(parameters.EffectiveDateLte); + Assert.False(parameters.RawQueryData.ContainsKey("effective_date[lte]")); } [Fact] @@ -93,12 +121,24 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Currency = null, Cursor = null, + EffectiveDateGt = null, + EffectiveDateGte = null, + EffectiveDateLt = null, + EffectiveDateLte = null, }; Assert.Null(parameters.Currency); Assert.True(parameters.RawQueryData.ContainsKey("currency")); Assert.Null(parameters.Cursor); Assert.True(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EffectiveDateGt); + Assert.True(parameters.RawQueryData.ContainsKey("effective_date[gt]")); + Assert.Null(parameters.EffectiveDateGte); + Assert.True(parameters.RawQueryData.ContainsKey("effective_date[gte]")); + Assert.Null(parameters.EffectiveDateLt); + Assert.True(parameters.RawQueryData.ContainsKey("effective_date[lt]")); + Assert.Null(parameters.EffectiveDateLte); + Assert.True(parameters.RawQueryData.ContainsKey("effective_date[lte]")); } [Fact] @@ -109,6 +149,10 @@ public void Url_Works() ExternalCustomerID = "external_customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IncludeAllBlocks = true, Limit = 1, }; @@ -117,7 +161,7 @@ public void Url_Works() Assert.Equal( new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits?currency=currency&cursor=cursor&include_all_blocks=true&limit=1" + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits?currency=currency&cursor=cursor&effective_date%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&effective_date%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&effective_date%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&effective_date%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&include_all_blocks=true&limit=1" ), url ); @@ -131,6 +175,10 @@ public void CopyConstructor_Works() ExternalCustomerID = "external_customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IncludeAllBlocks = true, Limit = 1, }; diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs index 22aa24df6..3c72f002f 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs @@ -28,6 +28,7 @@ public void FieldRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }; @@ -46,6 +47,7 @@ public void FieldRoundtrip_Works() }, ]; double expectedMaximumInitialBalance = 0; + Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedPerUnitCostBasis = "per_unit_cost_basis"; ApiEnum expectedStatus = CreditListByExternalIDResponseStatus.Active; @@ -60,6 +62,13 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFilters[i], model.Filters[i]); } Assert.Equal(expectedMaximumInitialBalance, model.MaximumInitialBalance); + 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(expectedPerUnitCostBasis, model.PerUnitCostBasis); Assert.Equal(expectedStatus, model.Status); } @@ -83,6 +92,7 @@ public void SerializationRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }; @@ -115,6 +125,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }; @@ -140,6 +151,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; double expectedMaximumInitialBalance = 0; + Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedPerUnitCostBasis = "per_unit_cost_basis"; ApiEnum expectedStatus = CreditListByExternalIDResponseStatus.Active; @@ -154,6 +166,13 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFilters[i], deserialized.Filters[i]); } Assert.Equal(expectedMaximumInitialBalance, deserialized.MaximumInitialBalance); + 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(expectedPerUnitCostBasis, deserialized.PerUnitCostBasis); Assert.Equal(expectedStatus, deserialized.Status); } @@ -177,6 +196,7 @@ public void Validation_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }; @@ -203,6 +223,7 @@ public void CopyConstructor_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }; diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListPageResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListPageResponseTest.cs index 0c0cf689b..70d0c6e26 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListPageResponseTest.cs @@ -32,6 +32,7 @@ public void FieldRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }, @@ -57,6 +58,7 @@ public void FieldRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }, @@ -98,6 +100,7 @@ public void SerializationRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }, @@ -137,6 +140,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }, @@ -169,6 +173,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }, @@ -210,6 +215,7 @@ public void Validation_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }, @@ -243,6 +249,7 @@ public void CopyConstructor_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }, diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs index 422638a84..13838f711 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs @@ -13,6 +13,10 @@ public void FieldRoundtrip_Works() CustomerID = "customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IncludeAllBlocks = true, Limit = 1, }; @@ -20,12 +24,20 @@ public void FieldRoundtrip_Works() string expectedCustomerID = "customer_id"; string expectedCurrency = "currency"; string expectedCursor = "cursor"; + DateTimeOffset expectedEffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedEffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedEffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedEffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); bool expectedIncludeAllBlocks = true; long expectedLimit = 1; Assert.Equal(expectedCustomerID, parameters.CustomerID); Assert.Equal(expectedCurrency, parameters.Currency); Assert.Equal(expectedCursor, parameters.Cursor); + Assert.Equal(expectedEffectiveDateGt, parameters.EffectiveDateGt); + Assert.Equal(expectedEffectiveDateGte, parameters.EffectiveDateGte); + Assert.Equal(expectedEffectiveDateLt, parameters.EffectiveDateLt); + Assert.Equal(expectedEffectiveDateLte, parameters.EffectiveDateLte); Assert.Equal(expectedIncludeAllBlocks, parameters.IncludeAllBlocks); Assert.Equal(expectedLimit, parameters.Limit); } @@ -38,6 +50,10 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() CustomerID = "customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; Assert.Null(parameters.IncludeAllBlocks); @@ -54,6 +70,10 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() CustomerID = "customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), // Null should be interpreted as omitted for these properties IncludeAllBlocks = null, @@ -80,6 +100,14 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Assert.False(parameters.RawQueryData.ContainsKey("currency")); Assert.Null(parameters.Cursor); Assert.False(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EffectiveDateGt); + Assert.False(parameters.RawQueryData.ContainsKey("effective_date[gt]")); + Assert.Null(parameters.EffectiveDateGte); + Assert.False(parameters.RawQueryData.ContainsKey("effective_date[gte]")); + Assert.Null(parameters.EffectiveDateLt); + Assert.False(parameters.RawQueryData.ContainsKey("effective_date[lt]")); + Assert.Null(parameters.EffectiveDateLte); + Assert.False(parameters.RawQueryData.ContainsKey("effective_date[lte]")); } [Fact] @@ -93,12 +121,24 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Currency = null, Cursor = null, + EffectiveDateGt = null, + EffectiveDateGte = null, + EffectiveDateLt = null, + EffectiveDateLte = null, }; Assert.Null(parameters.Currency); Assert.True(parameters.RawQueryData.ContainsKey("currency")); Assert.Null(parameters.Cursor); Assert.True(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EffectiveDateGt); + Assert.True(parameters.RawQueryData.ContainsKey("effective_date[gt]")); + Assert.Null(parameters.EffectiveDateGte); + Assert.True(parameters.RawQueryData.ContainsKey("effective_date[gte]")); + Assert.Null(parameters.EffectiveDateLt); + Assert.True(parameters.RawQueryData.ContainsKey("effective_date[lt]")); + Assert.Null(parameters.EffectiveDateLte); + Assert.True(parameters.RawQueryData.ContainsKey("effective_date[lte]")); } [Fact] @@ -109,6 +149,10 @@ public void Url_Works() CustomerID = "customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IncludeAllBlocks = true, Limit = 1, }; @@ -117,7 +161,7 @@ public void Url_Works() Assert.Equal( new Uri( - "https://api.withorb.com/v1/customers/customer_id/credits?currency=currency&cursor=cursor&include_all_blocks=true&limit=1" + "https://api.withorb.com/v1/customers/customer_id/credits?currency=currency&cursor=cursor&effective_date%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&effective_date%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&effective_date%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&effective_date%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&include_all_blocks=true&limit=1" ), url ); @@ -131,6 +175,10 @@ public void CopyConstructor_Works() CustomerID = "customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IncludeAllBlocks = true, Limit = 1, }; diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs index e1d4930a5..19b18c788 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs @@ -28,6 +28,7 @@ public void FieldRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; @@ -46,6 +47,7 @@ public void FieldRoundtrip_Works() }, ]; double expectedMaximumInitialBalance = 0; + Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedPerUnitCostBasis = "per_unit_cost_basis"; ApiEnum expectedStatus = Status.Active; @@ -59,6 +61,13 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFilters[i], model.Filters[i]); } Assert.Equal(expectedMaximumInitialBalance, model.MaximumInitialBalance); + 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(expectedPerUnitCostBasis, model.PerUnitCostBasis); Assert.Equal(expectedStatus, model.Status); } @@ -82,6 +91,7 @@ public void SerializationRoundtrip_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; @@ -114,6 +124,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; @@ -139,6 +150,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; double expectedMaximumInitialBalance = 0; + Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedPerUnitCostBasis = "per_unit_cost_basis"; ApiEnum expectedStatus = Status.Active; @@ -152,6 +164,13 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFilters[i], deserialized.Filters[i]); } Assert.Equal(expectedMaximumInitialBalance, deserialized.MaximumInitialBalance); + 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(expectedPerUnitCostBasis, deserialized.PerUnitCostBasis); Assert.Equal(expectedStatus, deserialized.Status); } @@ -175,6 +194,7 @@ public void Validation_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; @@ -201,6 +221,7 @@ public void CopyConstructor_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; diff --git a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs index dc2c89198..5ea290e11 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs @@ -84,6 +84,28 @@ public required double? MaximumInitialBalance init { this._rawData.Set("maximum_initial_balance", 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) + ); + } + } + public required string? PerUnitCostBasis { get @@ -116,6 +138,7 @@ public override void Validate() item.Validate(); } _ = this.MaximumInitialBalance; + _ = this.Metadata; _ = this.PerUnitCostBasis; this.Status.Validate(); } diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs index 5ccfb0775..5ef576bdc 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs @@ -17,6 +17,11 @@ 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. /// +/// Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, +/// `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. +/// This filters on when the credit block becomes effective, which may differ from +/// creation time for backdated 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. @@ -52,6 +57,46 @@ public string? Cursor init { this._rawQueryData.Set("cursor", value); } } + public DateTimeOffset? EffectiveDateGt + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[gt]"); + } + init { this._rawQueryData.Set("effective_date[gt]", value); } + } + + public DateTimeOffset? EffectiveDateGte + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[gte]"); + } + init { this._rawQueryData.Set("effective_date[gte]", value); } + } + + public DateTimeOffset? EffectiveDateLt + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[lt]"); + } + init { this._rawQueryData.Set("effective_date[lt]", value); } + } + + public DateTimeOffset? EffectiveDateLte + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[lte]"); + } + init { this._rawQueryData.Set("effective_date[lte]", value); } + } + /// /// If set to True, all expired and depleted blocks, as well as active block /// will be returned. diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs index 5d8d6a1e1..88039fd6d 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs @@ -86,6 +86,28 @@ public required double? MaximumInitialBalance init { this._rawData.Set("maximum_initial_balance", 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) + ); + } + } + public required string? PerUnitCostBasis { get @@ -120,6 +142,7 @@ public override void Validate() item.Validate(); } _ = this.MaximumInitialBalance; + _ = this.Metadata; _ = this.PerUnitCostBasis; this.Status.Validate(); } diff --git a/src/Orb/Models/Customers/Credits/CreditListParams.cs b/src/Orb/Models/Customers/Credits/CreditListParams.cs index 931ab8ec4..7c7c9a295 100644 --- a/src/Orb/Models/Customers/Credits/CreditListParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListParams.cs @@ -17,6 +17,11 @@ 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. /// +/// Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, +/// `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. +/// This filters on when the credit block becomes effective, which may differ from +/// creation time for backdated 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. @@ -52,6 +57,46 @@ public string? Cursor init { this._rawQueryData.Set("cursor", value); } } + public DateTimeOffset? EffectiveDateGt + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[gt]"); + } + init { this._rawQueryData.Set("effective_date[gt]", value); } + } + + public DateTimeOffset? EffectiveDateGte + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[gte]"); + } + init { this._rawQueryData.Set("effective_date[gte]", value); } + } + + public DateTimeOffset? EffectiveDateLt + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[lt]"); + } + init { this._rawQueryData.Set("effective_date[lt]", value); } + } + + public DateTimeOffset? EffectiveDateLte + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[lte]"); + } + init { this._rawQueryData.Set("effective_date[lte]", value); } + } + /// /// If set to True, all expired and depleted blocks, as well as active block /// will be returned. diff --git a/src/Orb/Models/Customers/Credits/CreditListResponse.cs b/src/Orb/Models/Customers/Credits/CreditListResponse.cs index e0dd4cfce..533e93329 100644 --- a/src/Orb/Models/Customers/Credits/CreditListResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListResponse.cs @@ -79,6 +79,28 @@ public required double? MaximumInitialBalance init { this._rawData.Set("maximum_initial_balance", 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) + ); + } + } + public required string? PerUnitCostBasis { get @@ -111,6 +133,7 @@ public override void Validate() item.Validate(); } _ = this.MaximumInitialBalance; + _ = this.Metadata; _ = this.PerUnitCostBasis; this.Status.Validate(); } diff --git a/src/Orb/Services/Customers/ICreditService.cs b/src/Orb/Services/Customers/ICreditService.cs index 71044e6ab..3419b7bc6 100644 --- a/src/Orb/Services/Customers/ICreditService.cs +++ b/src/Orb/Services/Customers/ICreditService.cs @@ -39,6 +39,11 @@ public interface ICreditService /// /// Note that `currency` defaults to credits if not specified. To use a /// real world currency, set `currency` to an ISO 4217 string. + /// + /// Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + /// `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query + /// parameters. This filters on when the credit block becomes effective, which + /// may differ from creation time for backdated credits. /// Task List( CreditListParams parameters, @@ -60,6 +65,11 @@ Task List( /// /// Note that `currency` defaults to credits if not specified. To use a /// real world currency, set `currency` to an ISO 4217 string. + /// + /// Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + /// `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query + /// parameters. This filters on when the credit block becomes effective, which + /// may differ from creation time for backdated credits. /// Task ListByExternalID( CreditListByExternalIDParams parameters, From dba544be21d0115fd6ee8b3399fde64b16bcc3f8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 19:04:50 +0000 Subject: [PATCH 22/39] feat(api): manual updates added new endpoints --- .stats.yml | 4 +- .../CreditBlockListInvoicesParamsTest.cs | 37 + .../CreditBlockListInvoicesResponseTest.cs | 990 +++++++++ .../Invoices/InvoiceIssueSummaryParamsTest.cs | 71 + .../InvoiceIssueSummaryResponseTest.cs | 1767 +++++++++++++++++ .../LicenseTypeCreateParamsTest.cs | 47 + .../LicenseTypeCreateResponseTest.cs | 100 + .../LicenseTypeListPageResponseTest.cs | 165 ++ .../LicenseTypes/LicenseTypeListParamsTest.cs | 89 + .../LicenseTypeListResponseTest.cs | 100 + .../LicenseTypeRetrieveParamsTest.cs | 37 + .../LicenseTypeRetrieveResponseTest.cs | 100 + .../ExternalLicenseGetUsageParamsTest.cs | 178 ++ .../ExternalLicenseGetUsageResponseTest.cs | 494 +++++ .../Licenses/LicenseCreateParamsTest.cs | 99 + .../Licenses/LicenseCreateResponseTest.cs | 198 ++ .../Licenses/LicenseDeactivateParamsTest.cs | 70 + .../Licenses/LicenseDeactivateResponseTest.cs | 196 ++ .../Licenses/LicenseListPageResponseTest.cs | 194 ++ .../Models/Licenses/LicenseListParamsTest.cs | 211 ++ .../Licenses/LicenseListResponseTest.cs | 198 ++ .../LicenseRetrieveByExternalIDParamsTest.cs | 61 + ...LicenseRetrieveByExternalIDResponseTest.cs | 194 ++ .../Licenses/LicenseRetrieveParamsTest.cs | 37 + .../Licenses/LicenseRetrieveResponseTest.cs | 196 ++ .../Usage/UsageGetAllUsageParamsTest.cs | 169 ++ .../Usage/UsageGetAllUsageResponseTest.cs | 494 +++++ .../Licenses/Usage/UsageGetUsageParamsTest.cs | 156 ++ .../Usage/UsageGetUsageResponseTest.cs | 500 +++++ .../Services/CreditBlockServiceTest.cs | 11 + src/Orb.Tests/Services/InvoiceServiceTest.cs | 11 + src/Orb.Tests/Services/LicenseServiceTest.cs | 64 + .../Services/LicenseTypeServiceTest.cs | 37 + .../Licenses/ExternalLicenseServiceTest.cs | 17 + .../Services/Licenses/UsageServiceTest.cs | 27 + src/Orb/Core/ModelBase.cs | 25 + src/Orb/IOrbClient.cs | 8 + .../CreditBlockListInvoicesParams.cs | 127 ++ .../CreditBlockListInvoicesResponse.cs | 653 ++++++ .../Invoices/InvoiceIssueSummaryParams.cs | 170 ++ .../Invoices/InvoiceIssueSummaryResponse.cs | 1559 +++++++++++++++ .../LicenseTypes/LicenseTypeCreateParams.cs | 160 ++ .../LicenseTypes/LicenseTypeCreateResponse.cs | 104 + .../LicenseTypes/LicenseTypeListPage.cs | 80 + .../LicenseTypeListPageResponse.cs | 88 + .../LicenseTypes/LicenseTypeListParams.cs | 142 ++ .../LicenseTypes/LicenseTypeListResponse.cs | 102 + .../LicenseTypes/LicenseTypeRetrieveParams.cs | 115 ++ .../LicenseTypeRetrieveResponse.cs | 104 + .../ExternalLicenseGetUsageParams.cs | 228 +++ .../ExternalLicenseGetUsageResponse.cs | 309 +++ .../Models/Licenses/LicenseCreateParams.cs | 194 ++ .../Models/Licenses/LicenseCreateResponse.cs | 179 ++ .../Licenses/LicenseDeactivateParams.cs | 156 ++ .../Licenses/LicenseDeactivateResponse.cs | 182 ++ src/Orb/Models/Licenses/LicenseListPage.cs | 80 + .../Licenses/LicenseListPageResponse.cs | 86 + src/Orb/Models/Licenses/LicenseListParams.cs | 219 ++ .../Models/Licenses/LicenseListResponse.cs | 178 ++ .../LicenseRetrieveByExternalIDParams.cs | 143 ++ .../LicenseRetrieveByExternalIDResponse.cs | 187 ++ .../Models/Licenses/LicenseRetrieveParams.cs | 111 ++ .../Licenses/LicenseRetrieveResponse.cs | 179 ++ .../Licenses/Usage/UsageGetAllUsageParams.cs | 212 ++ .../Usage/UsageGetAllUsageResponse.cs | 304 +++ .../Licenses/Usage/UsageGetUsageParams.cs | 196 ++ .../Licenses/Usage/UsageGetUsageResponse.cs | 312 +++ src/Orb/OrbClient.cs | 28 + src/Orb/Services/CreditBlockService.cs | 69 + src/Orb/Services/ICreditBlockService.cs | 44 + src/Orb/Services/IInvoiceService.cs | 39 + src/Orb/Services/ILicenseService.cs | 186 ++ src/Orb/Services/ILicenseTypeService.cs | 119 ++ src/Orb/Services/InvoiceService.cs | 69 + src/Orb/Services/LicenseService.cs | 378 ++++ src/Orb/Services/LicenseTypeService.cs | 206 ++ .../Licenses/ExternalLicenseService.cs | 134 ++ .../Licenses/IExternalLicenseService.cs | 76 + src/Orb/Services/Licenses/IUsageService.cs | 94 + src/Orb/Services/Licenses/UsageService.cs | 162 ++ 80 files changed, 15813 insertions(+), 2 deletions(-) create mode 100644 src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesParamsTest.cs create mode 100644 src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesResponseTest.cs create mode 100644 src/Orb.Tests/Models/Invoices/InvoiceIssueSummaryParamsTest.cs create mode 100644 src/Orb.Tests/Models/Invoices/InvoiceIssueSummaryResponseTest.cs create mode 100644 src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateParamsTest.cs create mode 100644 src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateResponseTest.cs create mode 100644 src/Orb.Tests/Models/LicenseTypes/LicenseTypeListPageResponseTest.cs create mode 100644 src/Orb.Tests/Models/LicenseTypes/LicenseTypeListParamsTest.cs create mode 100644 src/Orb.Tests/Models/LicenseTypes/LicenseTypeListResponseTest.cs create mode 100644 src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveParamsTest.cs create mode 100644 src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParamsTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseCreateParamsTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseCreateResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseDeactivateParamsTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseDeactivateResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseListPageResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseListParamsTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseListResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseRetrieveByExternalIDParamsTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseRetrieveByExternalIDResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseRetrieveParamsTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/LicenseRetrieveResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageParamsTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageResponseTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageParamsTest.cs create mode 100644 src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageResponseTest.cs create mode 100644 src/Orb.Tests/Services/LicenseServiceTest.cs create mode 100644 src/Orb.Tests/Services/LicenseTypeServiceTest.cs create mode 100644 src/Orb.Tests/Services/Licenses/ExternalLicenseServiceTest.cs create mode 100644 src/Orb.Tests/Services/Licenses/UsageServiceTest.cs create mode 100644 src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs create mode 100644 src/Orb/Models/CreditBlocks/CreditBlockListInvoicesResponse.cs create mode 100644 src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs create mode 100644 src/Orb/Models/Invoices/InvoiceIssueSummaryResponse.cs create mode 100644 src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs create mode 100644 src/Orb/Models/LicenseTypes/LicenseTypeCreateResponse.cs create mode 100644 src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs create mode 100644 src/Orb/Models/LicenseTypes/LicenseTypeListPageResponse.cs create mode 100644 src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs create mode 100644 src/Orb/Models/LicenseTypes/LicenseTypeListResponse.cs create mode 100644 src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs create mode 100644 src/Orb/Models/LicenseTypes/LicenseTypeRetrieveResponse.cs create mode 100644 src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs create mode 100644 src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponse.cs create mode 100644 src/Orb/Models/Licenses/LicenseCreateParams.cs create mode 100644 src/Orb/Models/Licenses/LicenseCreateResponse.cs create mode 100644 src/Orb/Models/Licenses/LicenseDeactivateParams.cs create mode 100644 src/Orb/Models/Licenses/LicenseDeactivateResponse.cs create mode 100644 src/Orb/Models/Licenses/LicenseListPage.cs create mode 100644 src/Orb/Models/Licenses/LicenseListPageResponse.cs create mode 100644 src/Orb/Models/Licenses/LicenseListParams.cs create mode 100644 src/Orb/Models/Licenses/LicenseListResponse.cs create mode 100644 src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs create mode 100644 src/Orb/Models/Licenses/LicenseRetrieveByExternalIDResponse.cs create mode 100644 src/Orb/Models/Licenses/LicenseRetrieveParams.cs create mode 100644 src/Orb/Models/Licenses/LicenseRetrieveResponse.cs create mode 100644 src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs create mode 100644 src/Orb/Models/Licenses/Usage/UsageGetAllUsageResponse.cs create mode 100644 src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs create mode 100644 src/Orb/Models/Licenses/Usage/UsageGetUsageResponse.cs create mode 100644 src/Orb/Services/ILicenseService.cs create mode 100644 src/Orb/Services/ILicenseTypeService.cs create mode 100644 src/Orb/Services/LicenseService.cs create mode 100644 src/Orb/Services/LicenseTypeService.cs create mode 100644 src/Orb/Services/Licenses/ExternalLicenseService.cs create mode 100644 src/Orb/Services/Licenses/IExternalLicenseService.cs create mode 100644 src/Orb/Services/Licenses/IUsageService.cs create mode 100644 src/Orb/Services/Licenses/UsageService.cs diff --git a/.stats.yml b/.stats.yml index 67224ec77..c80eee48c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 126 +configured_endpoints: 139 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c92fb451e13f157b3735f188acc8d57aa3adfbaac1683645e1ba4f432dd7a4f8.yml openapi_spec_hash: dbcd87ecfbd3976eb3b99ec6f9fbc606 -config_hash: bcf82bddb691f6be773ac6cae8c03b9a +config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesParamsTest.cs b/src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesParamsTest.cs new file mode 100644 index 000000000..8e700d124 --- /dev/null +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using Orb.Models.CreditBlocks; + +namespace Orb.Tests.Models.CreditBlocks; + +public class CreditBlockListInvoicesParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new CreditBlockListInvoicesParams { BlockID = "block_id" }; + + string expectedBlockID = "block_id"; + + Assert.Equal(expectedBlockID, parameters.BlockID); + } + + [Fact] + public void Url_Works() + { + CreditBlockListInvoicesParams parameters = new() { BlockID = "block_id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal(new Uri("https://api.withorb.com/v1/credit_blocks/block_id/invoices"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditBlockListInvoicesParams { BlockID = "block_id" }; + + CreditBlockListInvoicesParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesResponseTest.cs b/src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesResponseTest.cs new file mode 100644 index 000000000..9e9041b5e --- /dev/null +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesResponseTest.cs @@ -0,0 +1,990 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.CreditBlocks; +using Models = Orb.Models; + +namespace Orb.Tests.Models.CreditBlocks; + +public class CreditBlockListInvoicesResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CreditBlockListInvoicesResponse + { + Block = new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }, + Invoices = + [ + new() + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }, + ], + }; + + Block expectedBlock = new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }; + List expectedInvoices = + [ + new() + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }, + ]; + + Assert.Equal(expectedBlock, model.Block); + Assert.Equal(expectedInvoices.Count, model.Invoices.Count); + for (int i = 0; i < expectedInvoices.Count; i++) + { + Assert.Equal(expectedInvoices[i], model.Invoices[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CreditBlockListInvoicesResponse + { + Block = new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }, + Invoices = + [ + new() + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }, + ], + }; + + 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 CreditBlockListInvoicesResponse + { + Block = new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }, + Invoices = + [ + new() + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Block expectedBlock = new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }; + List expectedInvoices = + [ + new() + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }, + ]; + + Assert.Equal(expectedBlock, deserialized.Block); + Assert.Equal(expectedInvoices.Count, deserialized.Invoices.Count); + for (int i = 0; i < expectedInvoices.Count; i++) + { + Assert.Equal(expectedInvoices[i], deserialized.Invoices[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new CreditBlockListInvoicesResponse + { + Block = new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }, + Invoices = + [ + new() + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CreditBlockListInvoicesResponse + { + Block = new() + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }, + Invoices = + [ + new() + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }, + ], + }; + + CreditBlockListInvoicesResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BlockTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Block + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }; + + string expectedID = "id"; + double expectedBalance = 0; + DateTimeOffset expectedEffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + List expectedFilters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedMaximumInitialBalance = 0; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedPerUnitCostBasis = "per_unit_cost_basis"; + ApiEnum expectedStatus = BlockStatus.Active; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedBalance, model.Balance); + Assert.Equal(expectedEffectiveDate, model.EffectiveDate); + Assert.Equal(expectedExpiryDate, model.ExpiryDate); + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } + Assert.Equal(expectedMaximumInitialBalance, model.MaximumInitialBalance); + 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(expectedPerUnitCostBasis, model.PerUnitCostBasis); + Assert.Equal(expectedStatus, model.Status); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Block + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }; + + 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 Block + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + string expectedID = "id"; + double expectedBalance = 0; + DateTimeOffset expectedEffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + List expectedFilters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedMaximumInitialBalance = 0; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedPerUnitCostBasis = "per_unit_cost_basis"; + ApiEnum expectedStatus = BlockStatus.Active; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedBalance, deserialized.Balance); + Assert.Equal(expectedEffectiveDate, deserialized.EffectiveDate); + Assert.Equal(expectedExpiryDate, deserialized.ExpiryDate); + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } + Assert.Equal(expectedMaximumInitialBalance, deserialized.MaximumInitialBalance); + 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(expectedPerUnitCostBasis, deserialized.PerUnitCostBasis); + Assert.Equal(expectedStatus, deserialized.Status); + } + + [Fact] + public void Validation_Works() + { + var model = new Block + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Block + { + ID = "id", + Balance = 0, + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = BlockStatus.Active, + }; + + Block copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BlockFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BlockFilter + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }; + + ApiEnum expectedField = BlockFilterField.PriceID; + ApiEnum expectedOperator = BlockFilterOperator.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 BlockFilter + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.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 BlockFilter + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedField = BlockFilterField.PriceID; + ApiEnum expectedOperator = BlockFilterOperator.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 BlockFilter + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BlockFilter + { + Field = BlockFilterField.PriceID, + Operator = BlockFilterOperator.Includes, + Values = ["string"], + }; + + BlockFilter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BlockFilterFieldTest : TestBase +{ + [Theory] + [InlineData(BlockFilterField.PriceID)] + [InlineData(BlockFilterField.ItemID)] + [InlineData(BlockFilterField.PriceType)] + [InlineData(BlockFilterField.Currency)] + [InlineData(BlockFilterField.PricingUnitID)] + public void Validation_Works(BlockFilterField 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(BlockFilterField.PriceID)] + [InlineData(BlockFilterField.ItemID)] + [InlineData(BlockFilterField.PriceType)] + [InlineData(BlockFilterField.Currency)] + [InlineData(BlockFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(BlockFilterField 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 BlockFilterOperatorTest : TestBase +{ + [Theory] + [InlineData(BlockFilterOperator.Includes)] + [InlineData(BlockFilterOperator.Excludes)] + public void Validation_Works(BlockFilterOperator 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(BlockFilterOperator.Includes)] + [InlineData(BlockFilterOperator.Excludes)] + public void SerializationRoundtrip_Works(BlockFilterOperator 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 BlockStatusTest : TestBase +{ + [Theory] + [InlineData(BlockStatus.Active)] + [InlineData(BlockStatus.PendingPayment)] + public void Validation_Works(BlockStatus 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(BlockStatus.Active)] + [InlineData(BlockStatus.PendingPayment)] + public void SerializationRoundtrip_Works(BlockStatus 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 InvoiceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Invoice + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }; + + string expectedID = "id"; + Models::CustomerMinified expectedCustomer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }; + string expectedInvoiceNumber = "invoice_number"; + ApiEnum expectedStatus = InvoiceStatus.Issued; + Models::SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedCustomer, model.Customer); + Assert.Equal(expectedInvoiceNumber, model.InvoiceNumber); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedSubscription, model.Subscription); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Invoice + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }; + + 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 Invoice + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + Models::CustomerMinified expectedCustomer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }; + string expectedInvoiceNumber = "invoice_number"; + ApiEnum expectedStatus = InvoiceStatus.Issued; + Models::SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedCustomer, deserialized.Customer); + Assert.Equal(expectedInvoiceNumber, deserialized.InvoiceNumber); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedSubscription, deserialized.Subscription); + } + + [Fact] + public void Validation_Works() + { + var model = new Invoice + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Invoice + { + ID = "id", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + InvoiceNumber = "invoice_number", + Status = InvoiceStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + }; + + Invoice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class InvoiceStatusTest : TestBase +{ + [Theory] + [InlineData(InvoiceStatus.Issued)] + [InlineData(InvoiceStatus.Paid)] + [InlineData(InvoiceStatus.Synced)] + [InlineData(InvoiceStatus.Void)] + [InlineData(InvoiceStatus.Draft)] + public void Validation_Works(InvoiceStatus 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(InvoiceStatus.Issued)] + [InlineData(InvoiceStatus.Paid)] + [InlineData(InvoiceStatus.Synced)] + [InlineData(InvoiceStatus.Void)] + [InlineData(InvoiceStatus.Draft)] + public void SerializationRoundtrip_Works(InvoiceStatus 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/InvoiceIssueSummaryParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceIssueSummaryParamsTest.cs new file mode 100644 index 000000000..204a1a0c1 --- /dev/null +++ b/src/Orb.Tests/Models/Invoices/InvoiceIssueSummaryParamsTest.cs @@ -0,0 +1,71 @@ +using System; +using Orb.Models.Invoices; + +namespace Orb.Tests.Models.Invoices; + +public class InvoiceIssueSummaryParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new InvoiceIssueSummaryParams + { + InvoiceID = "invoice_id", + Synchronous = true, + }; + + string expectedInvoiceID = "invoice_id"; + bool expectedSynchronous = true; + + Assert.Equal(expectedInvoiceID, parameters.InvoiceID); + Assert.Equal(expectedSynchronous, parameters.Synchronous); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new InvoiceIssueSummaryParams { InvoiceID = "invoice_id" }; + + Assert.Null(parameters.Synchronous); + Assert.False(parameters.RawBodyData.ContainsKey("synchronous")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new InvoiceIssueSummaryParams + { + InvoiceID = "invoice_id", + + // Null should be interpreted as omitted for these properties + Synchronous = null, + }; + + Assert.Null(parameters.Synchronous); + Assert.False(parameters.RawBodyData.ContainsKey("synchronous")); + } + + [Fact] + public void Url_Works() + { + InvoiceIssueSummaryParams parameters = new() { InvoiceID = "invoice_id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/summary/invoice_id/issue"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceIssueSummaryParams + { + InvoiceID = "invoice_id", + Synchronous = true, + }; + + InvoiceIssueSummaryParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/Invoices/InvoiceIssueSummaryResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceIssueSummaryResponseTest.cs new file mode 100644 index 000000000..be159353e --- /dev/null +++ b/src/Orb.Tests/Models/Invoices/InvoiceIssueSummaryResponseTest.cs @@ -0,0 +1,1767 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models; +using Orb.Models.Invoices; + +namespace Orb.Tests.Models.Invoices; + +public class InvoiceIssueSummaryResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponse + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceIssueSummaryResponseInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceIssueSummaryResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + string expectedID = "id"; + string expectedAmountDue = "8.00"; + InvoiceIssueSummaryResponseAutoCollection expectedAutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + Address expectedBillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); + List expectedCreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ]; + string expectedCurrency = "USD"; + CustomerMinified expectedCustomer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }; + List expectedCustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ]; + CustomerTaxID expectedCustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }; + DateTimeOffset expectedDueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"); + DateTimeOffset expectedEligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedHostedInvoiceUrl = "hosted_invoice_url"; + DateTimeOffset expectedInvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"); + string expectedInvoiceNumber = "JYEFHK-00001"; + string expectedInvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb"; + ApiEnum expectedInvoiceSource = + InvoiceIssueSummaryResponseInvoiceSource.Subscription; + DateTimeOffset expectedIssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedIssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedMemo = "memo"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + DateTimeOffset expectedPaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + List expectedPaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ]; + DateTimeOffset expectedPaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedPaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Address expectedShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + ApiEnum expectedStatus = + InvoiceIssueSummaryResponseStatus.Issued; + SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); + DateTimeOffset expectedSyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedTotal = "8.00"; + DateTimeOffset expectedVoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + bool expectedWillAutoIssue = true; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedAmountDue, model.AmountDue); + Assert.Equal(expectedAutoCollection, model.AutoCollection); + Assert.Equal(expectedBillingAddress, model.BillingAddress); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedCreditNotes.Count, model.CreditNotes.Count); + for (int i = 0; i < expectedCreditNotes.Count; i++) + { + Assert.Equal(expectedCreditNotes[i], model.CreditNotes[i]); + } + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedCustomer, model.Customer); + Assert.Equal( + expectedCustomerBalanceTransactions.Count, + model.CustomerBalanceTransactions.Count + ); + for (int i = 0; i < expectedCustomerBalanceTransactions.Count; i++) + { + Assert.Equal( + expectedCustomerBalanceTransactions[i], + model.CustomerBalanceTransactions[i] + ); + } + Assert.Equal(expectedCustomerTaxID, model.CustomerTaxID); + Assert.Equal(expectedDueDate, model.DueDate); + Assert.Equal(expectedEligibleToIssueAt, model.EligibleToIssueAt); + Assert.Equal(expectedHostedInvoiceUrl, model.HostedInvoiceUrl); + Assert.Equal(expectedInvoiceDate, model.InvoiceDate); + Assert.Equal(expectedInvoiceNumber, model.InvoiceNumber); + Assert.Equal(expectedInvoicePdf, model.InvoicePdf); + Assert.Equal(expectedInvoiceSource, model.InvoiceSource); + Assert.Equal(expectedIssueFailedAt, model.IssueFailedAt); + Assert.Equal(expectedIssuedAt, model.IssuedAt); + Assert.Equal(expectedMemo, model.Memo); + 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(expectedPaidAt, model.PaidAt); + Assert.Equal(expectedPaymentAttempts.Count, model.PaymentAttempts.Count); + for (int i = 0; i < expectedPaymentAttempts.Count; i++) + { + Assert.Equal(expectedPaymentAttempts[i], model.PaymentAttempts[i]); + } + Assert.Equal(expectedPaymentFailedAt, model.PaymentFailedAt); + Assert.Equal(expectedPaymentStartedAt, model.PaymentStartedAt); + Assert.Equal(expectedScheduledIssueAt, model.ScheduledIssueAt); + Assert.Equal(expectedShippingAddress, model.ShippingAddress); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedSubscription, model.Subscription); + Assert.Equal(expectedSyncFailedAt, model.SyncFailedAt); + Assert.Equal(expectedTotal, model.Total); + Assert.Equal(expectedVoidedAt, model.VoidedAt); + Assert.Equal(expectedWillAutoIssue, model.WillAutoIssue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponse + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceIssueSummaryResponseInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceIssueSummaryResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = 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 InvoiceIssueSummaryResponse + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceIssueSummaryResponseInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceIssueSummaryResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedAmountDue = "8.00"; + InvoiceIssueSummaryResponseAutoCollection expectedAutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + Address expectedBillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); + List expectedCreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ]; + string expectedCurrency = "USD"; + CustomerMinified expectedCustomer = new() + { + ID = "id", + ExternalCustomerID = "external_customer_id", + }; + List expectedCustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ]; + CustomerTaxID expectedCustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }; + DateTimeOffset expectedDueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"); + DateTimeOffset expectedEligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedHostedInvoiceUrl = "hosted_invoice_url"; + DateTimeOffset expectedInvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"); + string expectedInvoiceNumber = "JYEFHK-00001"; + string expectedInvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb"; + ApiEnum expectedInvoiceSource = + InvoiceIssueSummaryResponseInvoiceSource.Subscription; + DateTimeOffset expectedIssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedIssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedMemo = "memo"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + DateTimeOffset expectedPaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + List expectedPaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ]; + DateTimeOffset expectedPaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedPaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DateTimeOffset expectedScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Address expectedShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + ApiEnum expectedStatus = + InvoiceIssueSummaryResponseStatus.Issued; + SubscriptionMinified expectedSubscription = new("VDGsT23osdLb84KD"); + DateTimeOffset expectedSyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedTotal = "8.00"; + DateTimeOffset expectedVoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + bool expectedWillAutoIssue = true; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedAmountDue, deserialized.AmountDue); + Assert.Equal(expectedAutoCollection, deserialized.AutoCollection); + Assert.Equal(expectedBillingAddress, deserialized.BillingAddress); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedCreditNotes.Count, deserialized.CreditNotes.Count); + for (int i = 0; i < expectedCreditNotes.Count; i++) + { + Assert.Equal(expectedCreditNotes[i], deserialized.CreditNotes[i]); + } + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedCustomer, deserialized.Customer); + Assert.Equal( + expectedCustomerBalanceTransactions.Count, + deserialized.CustomerBalanceTransactions.Count + ); + for (int i = 0; i < expectedCustomerBalanceTransactions.Count; i++) + { + Assert.Equal( + expectedCustomerBalanceTransactions[i], + deserialized.CustomerBalanceTransactions[i] + ); + } + Assert.Equal(expectedCustomerTaxID, deserialized.CustomerTaxID); + Assert.Equal(expectedDueDate, deserialized.DueDate); + Assert.Equal(expectedEligibleToIssueAt, deserialized.EligibleToIssueAt); + Assert.Equal(expectedHostedInvoiceUrl, deserialized.HostedInvoiceUrl); + Assert.Equal(expectedInvoiceDate, deserialized.InvoiceDate); + Assert.Equal(expectedInvoiceNumber, deserialized.InvoiceNumber); + Assert.Equal(expectedInvoicePdf, deserialized.InvoicePdf); + Assert.Equal(expectedInvoiceSource, deserialized.InvoiceSource); + Assert.Equal(expectedIssueFailedAt, deserialized.IssueFailedAt); + Assert.Equal(expectedIssuedAt, deserialized.IssuedAt); + Assert.Equal(expectedMemo, deserialized.Memo); + 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(expectedPaidAt, deserialized.PaidAt); + Assert.Equal(expectedPaymentAttempts.Count, deserialized.PaymentAttempts.Count); + for (int i = 0; i < expectedPaymentAttempts.Count; i++) + { + Assert.Equal(expectedPaymentAttempts[i], deserialized.PaymentAttempts[i]); + } + Assert.Equal(expectedPaymentFailedAt, deserialized.PaymentFailedAt); + Assert.Equal(expectedPaymentStartedAt, deserialized.PaymentStartedAt); + Assert.Equal(expectedScheduledIssueAt, deserialized.ScheduledIssueAt); + Assert.Equal(expectedShippingAddress, deserialized.ShippingAddress); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedSubscription, deserialized.Subscription); + Assert.Equal(expectedSyncFailedAt, deserialized.SyncFailedAt); + Assert.Equal(expectedTotal, deserialized.Total); + Assert.Equal(expectedVoidedAt, deserialized.VoidedAt); + Assert.Equal(expectedWillAutoIssue, deserialized.WillAutoIssue); + } + + [Fact] + public void Validation_Works() + { + var model = new InvoiceIssueSummaryResponse + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceIssueSummaryResponseInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceIssueSummaryResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceIssueSummaryResponse + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceIssueSummaryResponseInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceIssueSummaryResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }; + + InvoiceIssueSummaryResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class InvoiceIssueSummaryResponseAutoCollectionTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponseAutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + bool expectedEnabled = true; + DateTimeOffset expectedNextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedNumAttempts = 0; + DateTimeOffset expectedPreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ); + + Assert.Equal(expectedEnabled, model.Enabled); + Assert.Equal(expectedNextAttemptAt, model.NextAttemptAt); + Assert.Equal(expectedNumAttempts, model.NumAttempts); + Assert.Equal(expectedPreviouslyAttemptedAt, model.PreviouslyAttemptedAt); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponseAutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = 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 InvoiceIssueSummaryResponseAutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = 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); + + bool expectedEnabled = true; + DateTimeOffset expectedNextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedNumAttempts = 0; + DateTimeOffset expectedPreviouslyAttemptedAt = DateTimeOffset.Parse( + "2019-12-27T18:11:19.117Z" + ); + + Assert.Equal(expectedEnabled, deserialized.Enabled); + Assert.Equal(expectedNextAttemptAt, deserialized.NextAttemptAt); + Assert.Equal(expectedNumAttempts, deserialized.NumAttempts); + Assert.Equal(expectedPreviouslyAttemptedAt, deserialized.PreviouslyAttemptedAt); + } + + [Fact] + public void Validation_Works() + { + var model = new InvoiceIssueSummaryResponseAutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceIssueSummaryResponseAutoCollection + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + InvoiceIssueSummaryResponseAutoCollection copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class InvoiceIssueSummaryResponseCreditNoteTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponseCreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + string expectedID = "id"; + string expectedCreditNoteNumber = "credit_note_number"; + string expectedMemo = "memo"; + string expectedReason = "reason"; + string expectedTotal = "total"; + string expectedType = "type"; + DateTimeOffset expectedVoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedCreditNoteNumber, model.CreditNoteNumber); + Assert.Equal(expectedMemo, model.Memo); + Assert.Equal(expectedReason, model.Reason); + Assert.Equal(expectedTotal, model.Total); + Assert.Equal(expectedType, model.Type); + Assert.Equal(expectedVoidedAt, model.VoidedAt); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponseCreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + 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 InvoiceIssueSummaryResponseCreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedCreditNoteNumber = "credit_note_number"; + string expectedMemo = "memo"; + string expectedReason = "reason"; + string expectedTotal = "total"; + string expectedType = "type"; + DateTimeOffset expectedVoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedCreditNoteNumber, deserialized.CreditNoteNumber); + Assert.Equal(expectedMemo, deserialized.Memo); + Assert.Equal(expectedReason, deserialized.Reason); + Assert.Equal(expectedTotal, deserialized.Total); + Assert.Equal(expectedType, deserialized.Type); + Assert.Equal(expectedVoidedAt, deserialized.VoidedAt); + } + + [Fact] + public void Validation_Works() + { + var model = new InvoiceIssueSummaryResponseCreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceIssueSummaryResponseCreditNote + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }; + + InvoiceIssueSummaryResponseCreditNote copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class InvoiceIssueSummaryResponseCustomerBalanceTransactionTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponseCustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }; + + string expectedID = "cgZa3SXcsPTVyC4Y"; + ApiEnum< + string, + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction + > expectedAction = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice; + string expectedAmount = "11.00"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); + CreditNoteTiny expectedCreditNote = new("id"); + string expectedDescription = "An optional description"; + string expectedEndingBalance = "22.00"; + InvoiceTiny expectedInvoice = new("gXcsPTVyC4YZa3Sc"); + string expectedStartingBalance = "33.00"; + ApiEnum expectedType = + InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedAction, model.Action); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedCreditNote, model.CreditNote); + Assert.Equal(expectedDescription, model.Description); + Assert.Equal(expectedEndingBalance, model.EndingBalance); + Assert.Equal(expectedInvoice, model.Invoice); + Assert.Equal(expectedStartingBalance, model.StartingBalance); + Assert.Equal(expectedType, model.Type); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponseCustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }; + + 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 InvoiceIssueSummaryResponseCustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "cgZa3SXcsPTVyC4Y"; + ApiEnum< + string, + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction + > expectedAction = + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice; + string expectedAmount = "11.00"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"); + CreditNoteTiny expectedCreditNote = new("id"); + string expectedDescription = "An optional description"; + string expectedEndingBalance = "22.00"; + InvoiceTiny expectedInvoice = new("gXcsPTVyC4YZa3Sc"); + string expectedStartingBalance = "33.00"; + ApiEnum expectedType = + InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedAction, deserialized.Action); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedCreditNote, deserialized.CreditNote); + Assert.Equal(expectedDescription, deserialized.Description); + Assert.Equal(expectedEndingBalance, deserialized.EndingBalance); + Assert.Equal(expectedInvoice, deserialized.Invoice); + Assert.Equal(expectedStartingBalance, deserialized.StartingBalance); + Assert.Equal(expectedType, deserialized.Type); + } + + [Fact] + public void Validation_Works() + { + var model = new InvoiceIssueSummaryResponseCustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceIssueSummaryResponseCustomerBalanceTransaction + { + ID = "cgZa3SXcsPTVyC4Y", + Action = InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + }; + + InvoiceIssueSummaryResponseCustomerBalanceTransaction copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class InvoiceIssueSummaryResponseCustomerBalanceTransactionActionTest : TestBase +{ + [Theory] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ManualAdjustment)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ProratedRefund)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.RevertProratedRefund)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ReturnFromVoiding)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteApplied)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteVoided)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.OverpaymentRefund)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ExternalPayment)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.SmallInvoiceCarryover)] + public void Validation_Works( + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction 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(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ManualAdjustment)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ProratedRefund)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.RevertProratedRefund)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ReturnFromVoiding)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteApplied)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteVoided)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.OverpaymentRefund)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ExternalPayment)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.SmallInvoiceCarryover)] + public void SerializationRoundtrip_Works( + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction 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 InvoiceIssueSummaryResponseCustomerBalanceTransactionTypeTest : TestBase +{ + [Theory] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Decrement)] + public void Validation_Works(InvoiceIssueSummaryResponseCustomerBalanceTransactionType 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(InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment)] + [InlineData(InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Decrement)] + public void SerializationRoundtrip_Works( + InvoiceIssueSummaryResponseCustomerBalanceTransactionType 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 InvoiceIssueSummaryResponseInvoiceSourceTest : TestBase +{ + [Theory] + [InlineData(InvoiceIssueSummaryResponseInvoiceSource.Subscription)] + [InlineData(InvoiceIssueSummaryResponseInvoiceSource.Partial)] + [InlineData(InvoiceIssueSummaryResponseInvoiceSource.OneOff)] + public void Validation_Works(InvoiceIssueSummaryResponseInvoiceSource 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(InvoiceIssueSummaryResponseInvoiceSource.Subscription)] + [InlineData(InvoiceIssueSummaryResponseInvoiceSource.Partial)] + [InlineData(InvoiceIssueSummaryResponseInvoiceSource.OneOff)] + public void SerializationRoundtrip_Works(InvoiceIssueSummaryResponseInvoiceSource 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 InvoiceIssueSummaryResponsePaymentAttemptTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponsePaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }; + + string expectedID = "id"; + string expectedAmount = "amount"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum< + string, + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider + > expectedPaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe; + string expectedPaymentProviderID = "payment_provider_id"; + string expectedReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb"; + bool expectedSucceeded = true; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCreatedAt, model.CreatedAt); + Assert.Equal(expectedPaymentProvider, model.PaymentProvider); + Assert.Equal(expectedPaymentProviderID, model.PaymentProviderID); + Assert.Equal(expectedReceiptPdf, model.ReceiptPdf); + Assert.Equal(expectedSucceeded, model.Succeeded); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new InvoiceIssueSummaryResponsePaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = 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 InvoiceIssueSummaryResponsePaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedAmount = "amount"; + DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum< + string, + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider + > expectedPaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe; + string expectedPaymentProviderID = "payment_provider_id"; + string expectedReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb"; + bool expectedSucceeded = true; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); + Assert.Equal(expectedPaymentProvider, deserialized.PaymentProvider); + Assert.Equal(expectedPaymentProviderID, deserialized.PaymentProviderID); + Assert.Equal(expectedReceiptPdf, deserialized.ReceiptPdf); + Assert.Equal(expectedSucceeded, deserialized.Succeeded); + } + + [Fact] + public void Validation_Works() + { + var model = new InvoiceIssueSummaryResponsePaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceIssueSummaryResponsePaymentAttempt + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }; + + InvoiceIssueSummaryResponsePaymentAttempt copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class InvoiceIssueSummaryResponsePaymentAttemptPaymentProviderTest : TestBase +{ + [Theory] + [InlineData(InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe)] + public void Validation_Works(InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider 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(InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe)] + public void SerializationRoundtrip_Works( + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider 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 InvoiceIssueSummaryResponseStatusTest : TestBase +{ + [Theory] + [InlineData(InvoiceIssueSummaryResponseStatus.Issued)] + [InlineData(InvoiceIssueSummaryResponseStatus.Paid)] + [InlineData(InvoiceIssueSummaryResponseStatus.Synced)] + [InlineData(InvoiceIssueSummaryResponseStatus.Void)] + [InlineData(InvoiceIssueSummaryResponseStatus.Draft)] + public void Validation_Works(InvoiceIssueSummaryResponseStatus 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(InvoiceIssueSummaryResponseStatus.Issued)] + [InlineData(InvoiceIssueSummaryResponseStatus.Paid)] + [InlineData(InvoiceIssueSummaryResponseStatus.Synced)] + [InlineData(InvoiceIssueSummaryResponseStatus.Void)] + [InlineData(InvoiceIssueSummaryResponseStatus.Draft)] + public void SerializationRoundtrip_Works(InvoiceIssueSummaryResponseStatus 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); + } +} diff --git a/src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateParamsTest.cs b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateParamsTest.cs new file mode 100644 index 000000000..a155049b2 --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateParamsTest.cs @@ -0,0 +1,47 @@ +using System; +using Orb.Models.LicenseTypes; + +namespace Orb.Tests.Models.LicenseTypes; + +public class LicenseTypeCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new LicenseTypeCreateParams + { + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedGroupingKey, parameters.GroupingKey); + Assert.Equal(expectedName, parameters.Name); + } + + [Fact] + public void Url_Works() + { + LicenseTypeCreateParams parameters = new() { GroupingKey = "grouping_key", Name = "name" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal(new Uri("https://api.withorb.com/v1/license_types"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseTypeCreateParams + { + GroupingKey = "grouping_key", + Name = "name", + }; + + LicenseTypeCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateResponseTest.cs b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateResponseTest.cs new file mode 100644 index 000000000..670a94bd7 --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateResponseTest.cs @@ -0,0 +1,100 @@ +using System.Text.Json; +using Orb.Core; +using Orb.Models.LicenseTypes; + +namespace Orb.Tests.Models.LicenseTypes; + +public class LicenseTypeCreateResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseTypeCreateResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseTypeCreateResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 LicenseTypeCreateResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseTypeCreateResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseTypeCreateResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + LicenseTypeCreateResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListPageResponseTest.cs b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListPageResponseTest.cs new file mode 100644 index 000000000..ddf56f405 --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListPageResponseTest.cs @@ -0,0 +1,165 @@ +using System.Collections.Generic; +using System.Text.Json; +using Orb.Core; +using Orb.Models; +using Orb.Models.LicenseTypes; + +namespace Orb.Tests.Models.LicenseTypes; + +public class LicenseTypeListPageResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseTypeListPageResponse + { + Data = + [ + new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + List expectedData = + [ + new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, model.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], model.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, model.PaginationMetadata); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseTypeListPageResponse + { + Data = + [ + new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + 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 LicenseTypeListPageResponse + { + Data = + [ + new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedData = + [ + new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, deserialized.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], deserialized.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, deserialized.PaginationMetadata); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseTypeListPageResponse + { + Data = + [ + new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseTypeListPageResponse + { + Data = + [ + new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + LicenseTypeListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListParamsTest.cs b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListParamsTest.cs new file mode 100644 index 000000000..ed24ff3f3 --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListParamsTest.cs @@ -0,0 +1,89 @@ +using System; +using Orb.Models.LicenseTypes; + +namespace Orb.Tests.Models.LicenseTypes; + +public class LicenseTypeListParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new LicenseTypeListParams { Cursor = "cursor", Limit = 1 }; + + string expectedCursor = "cursor"; + long expectedLimit = 1; + + Assert.Equal(expectedCursor, parameters.Cursor); + Assert.Equal(expectedLimit, parameters.Limit); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new LicenseTypeListParams { Cursor = "cursor" }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new LicenseTypeListParams + { + Cursor = "cursor", + + // Null should be interpreted as omitted for these properties + Limit = null, + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNullableParamsUnsetAreNotSet_Works() + { + var parameters = new LicenseTypeListParams { Limit = 1 }; + + Assert.Null(parameters.Cursor); + Assert.False(parameters.RawQueryData.ContainsKey("cursor")); + } + + [Fact] + public void OptionalNullableParamsSetToNullAreSetToNull_Works() + { + var parameters = new LicenseTypeListParams + { + Limit = 1, + + Cursor = null, + }; + + Assert.Null(parameters.Cursor); + Assert.True(parameters.RawQueryData.ContainsKey("cursor")); + } + + [Fact] + public void Url_Works() + { + LicenseTypeListParams parameters = new() { Cursor = "cursor", Limit = 1 }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal( + new Uri("https://api.withorb.com/v1/license_types?cursor=cursor&limit=1"), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseTypeListParams { Cursor = "cursor", Limit = 1 }; + + LicenseTypeListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListResponseTest.cs b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListResponseTest.cs new file mode 100644 index 000000000..a78ceaa0e --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListResponseTest.cs @@ -0,0 +1,100 @@ +using System.Text.Json; +using Orb.Core; +using Orb.Models.LicenseTypes; + +namespace Orb.Tests.Models.LicenseTypes; + +public class LicenseTypeListResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseTypeListResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseTypeListResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 LicenseTypeListResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseTypeListResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseTypeListResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + LicenseTypeListResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveParamsTest.cs b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveParamsTest.cs new file mode 100644 index 000000000..abfbe6e28 --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using Orb.Models.LicenseTypes; + +namespace Orb.Tests.Models.LicenseTypes; + +public class LicenseTypeRetrieveParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new LicenseTypeRetrieveParams { LicenseTypeID = "license_type_id" }; + + string expectedLicenseTypeID = "license_type_id"; + + Assert.Equal(expectedLicenseTypeID, parameters.LicenseTypeID); + } + + [Fact] + public void Url_Works() + { + LicenseTypeRetrieveParams parameters = new() { LicenseTypeID = "license_type_id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal(new Uri("https://api.withorb.com/v1/license_types/license_type_id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseTypeRetrieveParams { LicenseTypeID = "license_type_id" }; + + LicenseTypeRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveResponseTest.cs b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveResponseTest.cs new file mode 100644 index 000000000..7eedaee86 --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveResponseTest.cs @@ -0,0 +1,100 @@ +using System.Text.Json; +using Orb.Core; +using Orb.Models.LicenseTypes; + +namespace Orb.Tests.Models.LicenseTypes; + +public class LicenseTypeRetrieveResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseTypeRetrieveResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseTypeRetrieveResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + 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 LicenseTypeRetrieveResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseTypeRetrieveResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseTypeRetrieveResponse + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + LicenseTypeRetrieveResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParamsTest.cs b/src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParamsTest.cs new file mode 100644 index 000000000..d9568b25c --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParamsTest.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using Orb.Models.Licenses.ExternalLicenses; + +namespace Orb.Tests.Models.Licenses.ExternalLicenses; + +public class ExternalLicenseGetUsageParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new ExternalLicenseGetUsageParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + string expectedSubscriptionID = "subscription_id"; + string expectedCursor = "cursor"; + string expectedEndDate = "2019-12-27"; + List expectedGroupBy = ["string"]; + long expectedLimit = 1; + string expectedStartDate = "2019-12-27"; + + Assert.Equal(expectedExternalLicenseID, parameters.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, parameters.LicenseTypeID); + Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); + Assert.Equal(expectedCursor, parameters.Cursor); + Assert.Equal(expectedEndDate, parameters.EndDate); + Assert.NotNull(parameters.GroupBy); + Assert.Equal(expectedGroupBy.Count, parameters.GroupBy.Count); + for (int i = 0; i < expectedGroupBy.Count; i++) + { + Assert.Equal(expectedGroupBy[i], parameters.GroupBy[i]); + } + Assert.Equal(expectedLimit, parameters.Limit); + Assert.Equal(expectedStartDate, parameters.StartDate); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new ExternalLicenseGetUsageParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + StartDate = "2019-12-27", + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new ExternalLicenseGetUsageParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + StartDate = "2019-12-27", + + // Null should be interpreted as omitted for these properties + Limit = null, + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNullableParamsUnsetAreNotSet_Works() + { + var parameters = new ExternalLicenseGetUsageParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Limit = 1, + }; + + Assert.Null(parameters.Cursor); + Assert.False(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EndDate); + Assert.False(parameters.RawQueryData.ContainsKey("end_date")); + Assert.Null(parameters.GroupBy); + Assert.False(parameters.RawQueryData.ContainsKey("group_by")); + Assert.Null(parameters.StartDate); + Assert.False(parameters.RawQueryData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullableParamsSetToNullAreSetToNull_Works() + { + var parameters = new ExternalLicenseGetUsageParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Limit = 1, + + Cursor = null, + EndDate = null, + GroupBy = null, + StartDate = null, + }; + + Assert.Null(parameters.Cursor); + Assert.True(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EndDate); + Assert.True(parameters.RawQueryData.ContainsKey("end_date")); + Assert.Null(parameters.GroupBy); + Assert.True(parameters.RawQueryData.ContainsKey("group_by")); + Assert.Null(parameters.StartDate); + Assert.True(parameters.RawQueryData.ContainsKey("start_date")); + } + + [Fact] + public void Url_Works() + { + ExternalLicenseGetUsageParams parameters = new() + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal( + new Uri( + "https://api.withorb.com/v1/licenses/external_licenses/external_license_id/usage?license_type_id=license_type_id&subscription_id=subscription_id&cursor=cursor&end_date=2019-12-27&group_by%5b%5d=string&limit=1&start_date=2019-12-27" + ), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalLicenseGetUsageParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + ExternalLicenseGetUsageParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponseTest.cs b/src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponseTest.cs new file mode 100644 index 000000000..a08450686 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponseTest.cs @@ -0,0 +1,494 @@ +using System.Collections.Generic; +using System.Text.Json; +using Orb.Core; +using Orb.Models; +using Orb.Models.Licenses.ExternalLicenses; + +namespace Orb.Tests.Models.Licenses.ExternalLicenses; + +public class ExternalLicenseGetUsageResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ExternalLicenseGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + List expectedData = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, model.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], model.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, model.PaginationMetadata); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ExternalLicenseGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + 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 ExternalLicenseGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedData = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, deserialized.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], deserialized.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, deserialized.PaginationMetadata); + } + + [Fact] + public void Validation_Works() + { + var model = new ExternalLicenseGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ExternalLicenseGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + ExternalLicenseGetUsageResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + double expectedAllocatedCredits = 0; + double expectedConsumedCredits = 0; + string expectedEndDate = "2019-12-27"; + string expectedLicenseTypeID = "license_type_id"; + string expectedPricingUnit = "pricing_unit"; + double expectedRemainingCredits = 0; + string expectedStartDate = "2019-12-27"; + string expectedSubscriptionID = "subscription_id"; + double expectedAllocationEligibleCredits = 0; + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseID = "license_id"; + double expectedSharedPoolCredits = 0; + + Assert.Equal(expectedAllocatedCredits, model.AllocatedCredits); + Assert.Equal(expectedConsumedCredits, model.ConsumedCredits); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.Equal(expectedPricingUnit, model.PricingUnit); + Assert.Equal(expectedRemainingCredits, model.RemainingCredits); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedSubscriptionID, model.SubscriptionID); + Assert.Equal(expectedAllocationEligibleCredits, model.AllocationEligibleCredits); + Assert.Equal(expectedExternalLicenseID, model.ExternalLicenseID); + Assert.Equal(expectedLicenseID, model.LicenseID); + Assert.Equal(expectedSharedPoolCredits, model.SharedPoolCredits); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 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 Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + double expectedAllocatedCredits = 0; + double expectedConsumedCredits = 0; + string expectedEndDate = "2019-12-27"; + string expectedLicenseTypeID = "license_type_id"; + string expectedPricingUnit = "pricing_unit"; + double expectedRemainingCredits = 0; + string expectedStartDate = "2019-12-27"; + string expectedSubscriptionID = "subscription_id"; + double expectedAllocationEligibleCredits = 0; + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseID = "license_id"; + double expectedSharedPoolCredits = 0; + + Assert.Equal(expectedAllocatedCredits, deserialized.AllocatedCredits); + Assert.Equal(expectedConsumedCredits, deserialized.ConsumedCredits); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.Equal(expectedPricingUnit, deserialized.PricingUnit); + Assert.Equal(expectedRemainingCredits, deserialized.RemainingCredits); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedSubscriptionID, deserialized.SubscriptionID); + Assert.Equal(expectedAllocationEligibleCredits, deserialized.AllocationEligibleCredits); + Assert.Equal(expectedExternalLicenseID, deserialized.ExternalLicenseID); + Assert.Equal(expectedLicenseID, deserialized.LicenseID); + Assert.Equal(expectedSharedPoolCredits, deserialized.SharedPoolCredits); + } + + [Fact] + public void Validation_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + }; + + Assert.Null(model.AllocationEligibleCredits); + Assert.False(model.RawData.ContainsKey("allocation_eligible_credits")); + Assert.Null(model.ExternalLicenseID); + Assert.False(model.RawData.ContainsKey("external_license_id")); + Assert.Null(model.LicenseID); + Assert.False(model.RawData.ContainsKey("license_id")); + Assert.Null(model.SharedPoolCredits); + Assert.False(model.RawData.ContainsKey("shared_pool_credits")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + + AllocationEligibleCredits = null, + ExternalLicenseID = null, + LicenseID = null, + SharedPoolCredits = null, + }; + + Assert.Null(model.AllocationEligibleCredits); + Assert.True(model.RawData.ContainsKey("allocation_eligible_credits")); + Assert.Null(model.ExternalLicenseID); + Assert.True(model.RawData.ContainsKey("external_license_id")); + Assert.Null(model.LicenseID); + Assert.True(model.RawData.ContainsKey("license_id")); + Assert.Null(model.SharedPoolCredits); + Assert.True(model.RawData.ContainsKey("shared_pool_credits")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + + AllocationEligibleCredits = null, + ExternalLicenseID = null, + LicenseID = null, + SharedPoolCredits = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + Data copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/LicenseCreateParamsTest.cs b/src/Orb.Tests/Models/Licenses/LicenseCreateParamsTest.cs new file mode 100644 index 000000000..44b7d7341 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseCreateParamsTest.cs @@ -0,0 +1,99 @@ +using System; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseCreateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new LicenseCreateParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + EndDate = "2026-01-27", + StartDate = "2026-01-27", + }; + + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + string expectedSubscriptionID = "subscription_id"; + string expectedEndDate = "2026-01-27"; + string expectedStartDate = "2026-01-27"; + + Assert.Equal(expectedExternalLicenseID, parameters.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, parameters.LicenseTypeID); + Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); + Assert.Equal(expectedEndDate, parameters.EndDate); + Assert.Equal(expectedStartDate, parameters.StartDate); + } + + [Fact] + public void OptionalNullableParamsUnsetAreNotSet_Works() + { + var parameters = new LicenseCreateParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + }; + + Assert.Null(parameters.EndDate); + Assert.False(parameters.RawBodyData.ContainsKey("end_date")); + Assert.Null(parameters.StartDate); + Assert.False(parameters.RawBodyData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullableParamsSetToNullAreSetToNull_Works() + { + var parameters = new LicenseCreateParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + + EndDate = null, + StartDate = null, + }; + + Assert.Null(parameters.EndDate); + Assert.True(parameters.RawBodyData.ContainsKey("end_date")); + Assert.Null(parameters.StartDate); + Assert.True(parameters.RawBodyData.ContainsKey("start_date")); + } + + [Fact] + public void Url_Works() + { + LicenseCreateParams parameters = new() + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal(new Uri("https://api.withorb.com/v1/licenses"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseCreateParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + EndDate = "2026-01-27", + StartDate = "2026-01-27", + }; + + LicenseCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/LicenseCreateResponseTest.cs b/src/Orb.Tests/Models/Licenses/LicenseCreateResponseTest.cs new file mode 100644 index 000000000..3e3dc5034 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseCreateResponseTest.cs @@ -0,0 +1,198 @@ +using System; +using System.Text.Json; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseCreateResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseCreateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseCreateResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseCreateResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedExternalLicenseID, model.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedSubscriptionID, model.SubscriptionID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseCreateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseCreateResponseStatus.Active, + SubscriptionID = "subscription_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 LicenseCreateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseCreateResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseCreateResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedExternalLicenseID, deserialized.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedSubscriptionID, deserialized.SubscriptionID); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseCreateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseCreateResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseCreateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseCreateResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + LicenseCreateResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class LicenseCreateResponseStatusTest : TestBase +{ + [Theory] + [InlineData(LicenseCreateResponseStatus.Active)] + [InlineData(LicenseCreateResponseStatus.Inactive)] + public void Validation_Works(LicenseCreateResponseStatus 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(LicenseCreateResponseStatus.Active)] + [InlineData(LicenseCreateResponseStatus.Inactive)] + public void SerializationRoundtrip_Works(LicenseCreateResponseStatus 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/Licenses/LicenseDeactivateParamsTest.cs b/src/Orb.Tests/Models/Licenses/LicenseDeactivateParamsTest.cs new file mode 100644 index 000000000..7a7fb5038 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseDeactivateParamsTest.cs @@ -0,0 +1,70 @@ +using System; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseDeactivateParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new LicenseDeactivateParams + { + LicenseID = "license_id", + EndDate = "2026-01-27", + }; + + string expectedLicenseID = "license_id"; + string expectedEndDate = "2026-01-27"; + + Assert.Equal(expectedLicenseID, parameters.LicenseID); + Assert.Equal(expectedEndDate, parameters.EndDate); + } + + [Fact] + public void OptionalNullableParamsUnsetAreNotSet_Works() + { + var parameters = new LicenseDeactivateParams { LicenseID = "license_id" }; + + Assert.Null(parameters.EndDate); + Assert.False(parameters.RawBodyData.ContainsKey("end_date")); + } + + [Fact] + public void OptionalNullableParamsSetToNullAreSetToNull_Works() + { + var parameters = new LicenseDeactivateParams + { + LicenseID = "license_id", + + EndDate = null, + }; + + Assert.Null(parameters.EndDate); + Assert.True(parameters.RawBodyData.ContainsKey("end_date")); + } + + [Fact] + public void Url_Works() + { + LicenseDeactivateParams parameters = new() { LicenseID = "license_id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal(new Uri("https://api.withorb.com/v1/licenses/license_id/deactivate"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseDeactivateParams + { + LicenseID = "license_id", + EndDate = "2026-01-27", + }; + + LicenseDeactivateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/LicenseDeactivateResponseTest.cs b/src/Orb.Tests/Models/Licenses/LicenseDeactivateResponseTest.cs new file mode 100644 index 000000000..4af95c154 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseDeactivateResponseTest.cs @@ -0,0 +1,196 @@ +using System; +using System.Text.Json; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseDeactivateResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseDeactivateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseDeactivateResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseDeactivateResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedExternalLicenseID, model.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedSubscriptionID, model.SubscriptionID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseDeactivateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseDeactivateResponseStatus.Active, + SubscriptionID = "subscription_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 LicenseDeactivateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseDeactivateResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseDeactivateResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedExternalLicenseID, deserialized.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedSubscriptionID, deserialized.SubscriptionID); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseDeactivateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseDeactivateResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseDeactivateResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseDeactivateResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + LicenseDeactivateResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class LicenseDeactivateResponseStatusTest : TestBase +{ + [Theory] + [InlineData(LicenseDeactivateResponseStatus.Active)] + [InlineData(LicenseDeactivateResponseStatus.Inactive)] + public void Validation_Works(LicenseDeactivateResponseStatus 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(LicenseDeactivateResponseStatus.Active)] + [InlineData(LicenseDeactivateResponseStatus.Inactive)] + public void SerializationRoundtrip_Works(LicenseDeactivateResponseStatus 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); + } +} diff --git a/src/Orb.Tests/Models/Licenses/LicenseListPageResponseTest.cs b/src/Orb.Tests/Models/Licenses/LicenseListPageResponseTest.cs new file mode 100644 index 000000000..166b3a507 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseListPageResponseTest.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using Orb.Core; +using Orb.Models; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseListPageResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseListPageResponse + { + Data = + [ + new() + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + List expectedData = + [ + new() + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, model.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], model.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, model.PaginationMetadata); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseListPageResponse + { + Data = + [ + new() + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + 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 LicenseListPageResponse + { + Data = + [ + new() + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedData = + [ + new() + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, deserialized.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], deserialized.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, deserialized.PaginationMetadata); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseListPageResponse + { + Data = + [ + new() + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseListPageResponse + { + Data = + [ + new() + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + LicenseListPageResponse copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/LicenseListParamsTest.cs b/src/Orb.Tests/Models/Licenses/LicenseListParamsTest.cs new file mode 100644 index 000000000..9d73a020e --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseListParamsTest.cs @@ -0,0 +1,211 @@ +using System; +using System.Text.Json; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseListParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new LicenseListParams + { + SubscriptionID = "subscription_id", + Cursor = "cursor", + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + Limit = 1, + Status = Status.Active, + }; + + string expectedSubscriptionID = "subscription_id"; + string expectedCursor = "cursor"; + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + long expectedLimit = 1; + ApiEnum expectedStatus = Status.Active; + + Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); + Assert.Equal(expectedCursor, parameters.Cursor); + Assert.Equal(expectedExternalLicenseID, parameters.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, parameters.LicenseTypeID); + Assert.Equal(expectedLimit, parameters.Limit); + Assert.Equal(expectedStatus, parameters.Status); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new LicenseListParams + { + SubscriptionID = "subscription_id", + Cursor = "cursor", + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + Status = Status.Active, + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new LicenseListParams + { + SubscriptionID = "subscription_id", + Cursor = "cursor", + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + Status = Status.Active, + + // Null should be interpreted as omitted for these properties + Limit = null, + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNullableParamsUnsetAreNotSet_Works() + { + var parameters = new LicenseListParams { SubscriptionID = "subscription_id", Limit = 1 }; + + Assert.Null(parameters.Cursor); + Assert.False(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.ExternalLicenseID); + Assert.False(parameters.RawQueryData.ContainsKey("external_license_id")); + Assert.Null(parameters.LicenseTypeID); + Assert.False(parameters.RawQueryData.ContainsKey("license_type_id")); + Assert.Null(parameters.Status); + Assert.False(parameters.RawQueryData.ContainsKey("status")); + } + + [Fact] + public void OptionalNullableParamsSetToNullAreSetToNull_Works() + { + var parameters = new LicenseListParams + { + SubscriptionID = "subscription_id", + Limit = 1, + + Cursor = null, + ExternalLicenseID = null, + LicenseTypeID = null, + Status = null, + }; + + Assert.Null(parameters.Cursor); + Assert.True(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.ExternalLicenseID); + Assert.True(parameters.RawQueryData.ContainsKey("external_license_id")); + Assert.Null(parameters.LicenseTypeID); + Assert.True(parameters.RawQueryData.ContainsKey("license_type_id")); + Assert.Null(parameters.Status); + Assert.True(parameters.RawQueryData.ContainsKey("status")); + } + + [Fact] + public void Url_Works() + { + LicenseListParams parameters = new() + { + SubscriptionID = "subscription_id", + Cursor = "cursor", + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + Limit = 1, + Status = Status.Active, + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal( + new Uri( + "https://api.withorb.com/v1/licenses?subscription_id=subscription_id&cursor=cursor&external_license_id=external_license_id&license_type_id=license_type_id&limit=1&status=active" + ), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseListParams + { + SubscriptionID = "subscription_id", + Cursor = "cursor", + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + Limit = 1, + Status = Status.Active, + }; + + LicenseListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} + +public class StatusTest : TestBase +{ + [Theory] + [InlineData(Status.Active)] + [InlineData(Status.Inactive)] + public void Validation_Works(Status 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(Status.Active)] + [InlineData(Status.Inactive)] + public void SerializationRoundtrip_Works(Status 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/Licenses/LicenseListResponseTest.cs b/src/Orb.Tests/Models/Licenses/LicenseListResponseTest.cs new file mode 100644 index 000000000..dd4fa4a6e --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseListResponseTest.cs @@ -0,0 +1,198 @@ +using System; +using System.Text.Json; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseListResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseListResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseListResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedExternalLicenseID, model.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedSubscriptionID, model.SubscriptionID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseListResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_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 LicenseListResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseListResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedExternalLicenseID, deserialized.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedSubscriptionID, deserialized.SubscriptionID); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseListResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseListResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseListResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + LicenseListResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class LicenseListResponseStatusTest : TestBase +{ + [Theory] + [InlineData(LicenseListResponseStatus.Active)] + [InlineData(LicenseListResponseStatus.Inactive)] + public void Validation_Works(LicenseListResponseStatus 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(LicenseListResponseStatus.Active)] + [InlineData(LicenseListResponseStatus.Inactive)] + public void SerializationRoundtrip_Works(LicenseListResponseStatus 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/Licenses/LicenseRetrieveByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Licenses/LicenseRetrieveByExternalIDParamsTest.cs new file mode 100644 index 000000000..7b5950764 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseRetrieveByExternalIDParamsTest.cs @@ -0,0 +1,61 @@ +using System; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseRetrieveByExternalIDParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new LicenseRetrieveByExternalIDParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + }; + + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedExternalLicenseID, parameters.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, parameters.LicenseTypeID); + Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); + } + + [Fact] + public void Url_Works() + { + LicenseRetrieveByExternalIDParams parameters = new() + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal( + new Uri( + "https://api.withorb.com/v1/licenses/external_license_id/external_license_id?license_type_id=license_type_id&subscription_id=subscription_id" + ), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseRetrieveByExternalIDParams + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + }; + + LicenseRetrieveByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/LicenseRetrieveByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Licenses/LicenseRetrieveByExternalIDResponseTest.cs new file mode 100644 index 000000000..19a4d815e --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseRetrieveByExternalIDResponseTest.cs @@ -0,0 +1,194 @@ +using System; +using System.Text.Json; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseRetrieveByExternalIDResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseRetrieveByExternalIDResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveByExternalIDResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseRetrieveByExternalIDResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedExternalLicenseID, model.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedSubscriptionID, model.SubscriptionID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseRetrieveByExternalIDResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveByExternalIDResponseStatus.Active, + SubscriptionID = "subscription_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 LicenseRetrieveByExternalIDResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveByExternalIDResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseRetrieveByExternalIDResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedExternalLicenseID, deserialized.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedSubscriptionID, deserialized.SubscriptionID); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseRetrieveByExternalIDResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveByExternalIDResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseRetrieveByExternalIDResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveByExternalIDResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + LicenseRetrieveByExternalIDResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class LicenseRetrieveByExternalIDResponseStatusTest : TestBase +{ + [Theory] + [InlineData(LicenseRetrieveByExternalIDResponseStatus.Active)] + [InlineData(LicenseRetrieveByExternalIDResponseStatus.Inactive)] + public void Validation_Works(LicenseRetrieveByExternalIDResponseStatus 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(LicenseRetrieveByExternalIDResponseStatus.Active)] + [InlineData(LicenseRetrieveByExternalIDResponseStatus.Inactive)] + public void SerializationRoundtrip_Works(LicenseRetrieveByExternalIDResponseStatus 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); + } +} diff --git a/src/Orb.Tests/Models/Licenses/LicenseRetrieveParamsTest.cs b/src/Orb.Tests/Models/Licenses/LicenseRetrieveParamsTest.cs new file mode 100644 index 000000000..328f68bd5 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseRetrieveParamsTest.cs @@ -0,0 +1,37 @@ +using System; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseRetrieveParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new LicenseRetrieveParams { LicenseID = "license_id" }; + + string expectedLicenseID = "license_id"; + + Assert.Equal(expectedLicenseID, parameters.LicenseID); + } + + [Fact] + public void Url_Works() + { + LicenseRetrieveParams parameters = new() { LicenseID = "license_id" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal(new Uri("https://api.withorb.com/v1/licenses/license_id"), url); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseRetrieveParams { LicenseID = "license_id" }; + + LicenseRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/LicenseRetrieveResponseTest.cs b/src/Orb.Tests/Models/Licenses/LicenseRetrieveResponseTest.cs new file mode 100644 index 000000000..33965f0c1 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseRetrieveResponseTest.cs @@ -0,0 +1,196 @@ +using System; +using System.Text.Json; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses; + +namespace Orb.Tests.Models.Licenses; + +public class LicenseRetrieveResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseRetrieveResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseRetrieveResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedExternalLicenseID, model.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedStatus, model.Status); + Assert.Equal(expectedSubscriptionID, model.SubscriptionID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseRetrieveResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveResponseStatus.Active, + SubscriptionID = "subscription_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 LicenseRetrieveResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseTypeID = "license_type_id"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + ApiEnum expectedStatus = + LicenseRetrieveResponseStatus.Active; + string expectedSubscriptionID = "subscription_id"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedExternalLicenseID, deserialized.ExternalLicenseID); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedStatus, deserialized.Status); + Assert.Equal(expectedSubscriptionID, deserialized.SubscriptionID); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseRetrieveResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseRetrieveResponse + { + ID = "id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Status = LicenseRetrieveResponseStatus.Active, + SubscriptionID = "subscription_id", + }; + + LicenseRetrieveResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class LicenseRetrieveResponseStatusTest : TestBase +{ + [Theory] + [InlineData(LicenseRetrieveResponseStatus.Active)] + [InlineData(LicenseRetrieveResponseStatus.Inactive)] + public void Validation_Works(LicenseRetrieveResponseStatus 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(LicenseRetrieveResponseStatus.Active)] + [InlineData(LicenseRetrieveResponseStatus.Inactive)] + public void SerializationRoundtrip_Works(LicenseRetrieveResponseStatus 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); + } +} diff --git a/src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageParamsTest.cs b/src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageParamsTest.cs new file mode 100644 index 000000000..710c38da0 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageParamsTest.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using Orb.Models.Licenses.Usage; + +namespace Orb.Tests.Models.Licenses.Usage; + +public class UsageGetAllUsageParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new UsageGetAllUsageParams + { + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + string expectedLicenseTypeID = "license_type_id"; + string expectedSubscriptionID = "subscription_id"; + string expectedCursor = "cursor"; + string expectedEndDate = "2019-12-27"; + List expectedGroupBy = ["string"]; + long expectedLimit = 1; + string expectedStartDate = "2019-12-27"; + + Assert.Equal(expectedLicenseTypeID, parameters.LicenseTypeID); + Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); + Assert.Equal(expectedCursor, parameters.Cursor); + Assert.Equal(expectedEndDate, parameters.EndDate); + Assert.NotNull(parameters.GroupBy); + Assert.Equal(expectedGroupBy.Count, parameters.GroupBy.Count); + for (int i = 0; i < expectedGroupBy.Count; i++) + { + Assert.Equal(expectedGroupBy[i], parameters.GroupBy[i]); + } + Assert.Equal(expectedLimit, parameters.Limit); + Assert.Equal(expectedStartDate, parameters.StartDate); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new UsageGetAllUsageParams + { + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + StartDate = "2019-12-27", + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new UsageGetAllUsageParams + { + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + StartDate = "2019-12-27", + + // Null should be interpreted as omitted for these properties + Limit = null, + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNullableParamsUnsetAreNotSet_Works() + { + var parameters = new UsageGetAllUsageParams + { + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Limit = 1, + }; + + Assert.Null(parameters.Cursor); + Assert.False(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EndDate); + Assert.False(parameters.RawQueryData.ContainsKey("end_date")); + Assert.Null(parameters.GroupBy); + Assert.False(parameters.RawQueryData.ContainsKey("group_by")); + Assert.Null(parameters.StartDate); + Assert.False(parameters.RawQueryData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullableParamsSetToNullAreSetToNull_Works() + { + var parameters = new UsageGetAllUsageParams + { + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Limit = 1, + + Cursor = null, + EndDate = null, + GroupBy = null, + StartDate = null, + }; + + Assert.Null(parameters.Cursor); + Assert.True(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EndDate); + Assert.True(parameters.RawQueryData.ContainsKey("end_date")); + Assert.Null(parameters.GroupBy); + Assert.True(parameters.RawQueryData.ContainsKey("group_by")); + Assert.Null(parameters.StartDate); + Assert.True(parameters.RawQueryData.ContainsKey("start_date")); + } + + [Fact] + public void Url_Works() + { + UsageGetAllUsageParams parameters = new() + { + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal( + new Uri( + "https://api.withorb.com/v1/licenses/usage?license_type_id=license_type_id&subscription_id=subscription_id&cursor=cursor&end_date=2019-12-27&group_by%5b%5d=string&limit=1&start_date=2019-12-27" + ), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new UsageGetAllUsageParams + { + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + UsageGetAllUsageParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageResponseTest.cs b/src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageResponseTest.cs new file mode 100644 index 000000000..873d73168 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageResponseTest.cs @@ -0,0 +1,494 @@ +using System.Collections.Generic; +using System.Text.Json; +using Orb.Core; +using Orb.Models; +using Orb.Models.Licenses.Usage; + +namespace Orb.Tests.Models.Licenses.Usage; + +public class UsageGetAllUsageResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageGetAllUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + List expectedData = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, model.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], model.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, model.PaginationMetadata); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageGetAllUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + 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 UsageGetAllUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedData = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, deserialized.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], deserialized.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, deserialized.PaginationMetadata); + } + + [Fact] + public void Validation_Works() + { + var model = new UsageGetAllUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageGetAllUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + UsageGetAllUsageResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + double expectedAllocatedCredits = 0; + double expectedConsumedCredits = 0; + string expectedEndDate = "2019-12-27"; + string expectedLicenseTypeID = "license_type_id"; + string expectedPricingUnit = "pricing_unit"; + double expectedRemainingCredits = 0; + string expectedStartDate = "2019-12-27"; + string expectedSubscriptionID = "subscription_id"; + double expectedAllocationEligibleCredits = 0; + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseID = "license_id"; + double expectedSharedPoolCredits = 0; + + Assert.Equal(expectedAllocatedCredits, model.AllocatedCredits); + Assert.Equal(expectedConsumedCredits, model.ConsumedCredits); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.Equal(expectedPricingUnit, model.PricingUnit); + Assert.Equal(expectedRemainingCredits, model.RemainingCredits); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedSubscriptionID, model.SubscriptionID); + Assert.Equal(expectedAllocationEligibleCredits, model.AllocationEligibleCredits); + Assert.Equal(expectedExternalLicenseID, model.ExternalLicenseID); + Assert.Equal(expectedLicenseID, model.LicenseID); + Assert.Equal(expectedSharedPoolCredits, model.SharedPoolCredits); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 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 Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + double expectedAllocatedCredits = 0; + double expectedConsumedCredits = 0; + string expectedEndDate = "2019-12-27"; + string expectedLicenseTypeID = "license_type_id"; + string expectedPricingUnit = "pricing_unit"; + double expectedRemainingCredits = 0; + string expectedStartDate = "2019-12-27"; + string expectedSubscriptionID = "subscription_id"; + double expectedAllocationEligibleCredits = 0; + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseID = "license_id"; + double expectedSharedPoolCredits = 0; + + Assert.Equal(expectedAllocatedCredits, deserialized.AllocatedCredits); + Assert.Equal(expectedConsumedCredits, deserialized.ConsumedCredits); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.Equal(expectedPricingUnit, deserialized.PricingUnit); + Assert.Equal(expectedRemainingCredits, deserialized.RemainingCredits); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedSubscriptionID, deserialized.SubscriptionID); + Assert.Equal(expectedAllocationEligibleCredits, deserialized.AllocationEligibleCredits); + Assert.Equal(expectedExternalLicenseID, deserialized.ExternalLicenseID); + Assert.Equal(expectedLicenseID, deserialized.LicenseID); + Assert.Equal(expectedSharedPoolCredits, deserialized.SharedPoolCredits); + } + + [Fact] + public void Validation_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + }; + + Assert.Null(model.AllocationEligibleCredits); + Assert.False(model.RawData.ContainsKey("allocation_eligible_credits")); + Assert.Null(model.ExternalLicenseID); + Assert.False(model.RawData.ContainsKey("external_license_id")); + Assert.Null(model.LicenseID); + Assert.False(model.RawData.ContainsKey("license_id")); + Assert.Null(model.SharedPoolCredits); + Assert.False(model.RawData.ContainsKey("shared_pool_credits")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + + AllocationEligibleCredits = null, + ExternalLicenseID = null, + LicenseID = null, + SharedPoolCredits = null, + }; + + Assert.Null(model.AllocationEligibleCredits); + Assert.True(model.RawData.ContainsKey("allocation_eligible_credits")); + Assert.Null(model.ExternalLicenseID); + Assert.True(model.RawData.ContainsKey("external_license_id")); + Assert.Null(model.LicenseID); + Assert.True(model.RawData.ContainsKey("license_id")); + Assert.Null(model.SharedPoolCredits); + Assert.True(model.RawData.ContainsKey("shared_pool_credits")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + + AllocationEligibleCredits = null, + ExternalLicenseID = null, + LicenseID = null, + SharedPoolCredits = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Data + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + Data copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageParamsTest.cs b/src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageParamsTest.cs new file mode 100644 index 000000000..99797714e --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageParamsTest.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using Orb.Models.Licenses.Usage; + +namespace Orb.Tests.Models.Licenses.Usage; + +public class UsageGetUsageParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new UsageGetUsageParams + { + LicenseID = "license_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + string expectedLicenseID = "license_id"; + string expectedCursor = "cursor"; + string expectedEndDate = "2019-12-27"; + List expectedGroupBy = ["string"]; + long expectedLimit = 1; + string expectedStartDate = "2019-12-27"; + + Assert.Equal(expectedLicenseID, parameters.LicenseID); + Assert.Equal(expectedCursor, parameters.Cursor); + Assert.Equal(expectedEndDate, parameters.EndDate); + Assert.NotNull(parameters.GroupBy); + Assert.Equal(expectedGroupBy.Count, parameters.GroupBy.Count); + for (int i = 0; i < expectedGroupBy.Count; i++) + { + Assert.Equal(expectedGroupBy[i], parameters.GroupBy[i]); + } + Assert.Equal(expectedLimit, parameters.Limit); + Assert.Equal(expectedStartDate, parameters.StartDate); + } + + [Fact] + public void OptionalNonNullableParamsUnsetAreNotSet_Works() + { + var parameters = new UsageGetUsageParams + { + LicenseID = "license_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + StartDate = "2019-12-27", + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNonNullableParamsSetToNullAreNotSet_Works() + { + var parameters = new UsageGetUsageParams + { + LicenseID = "license_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + StartDate = "2019-12-27", + + // Null should be interpreted as omitted for these properties + Limit = null, + }; + + Assert.Null(parameters.Limit); + Assert.False(parameters.RawQueryData.ContainsKey("limit")); + } + + [Fact] + public void OptionalNullableParamsUnsetAreNotSet_Works() + { + var parameters = new UsageGetUsageParams { LicenseID = "license_id", Limit = 1 }; + + Assert.Null(parameters.Cursor); + Assert.False(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EndDate); + Assert.False(parameters.RawQueryData.ContainsKey("end_date")); + Assert.Null(parameters.GroupBy); + Assert.False(parameters.RawQueryData.ContainsKey("group_by")); + Assert.Null(parameters.StartDate); + Assert.False(parameters.RawQueryData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullableParamsSetToNullAreSetToNull_Works() + { + var parameters = new UsageGetUsageParams + { + LicenseID = "license_id", + Limit = 1, + + Cursor = null, + EndDate = null, + GroupBy = null, + StartDate = null, + }; + + Assert.Null(parameters.Cursor); + Assert.True(parameters.RawQueryData.ContainsKey("cursor")); + Assert.Null(parameters.EndDate); + Assert.True(parameters.RawQueryData.ContainsKey("end_date")); + Assert.Null(parameters.GroupBy); + Assert.True(parameters.RawQueryData.ContainsKey("group_by")); + Assert.Null(parameters.StartDate); + Assert.True(parameters.RawQueryData.ContainsKey("start_date")); + } + + [Fact] + public void Url_Works() + { + UsageGetUsageParams parameters = new() + { + LicenseID = "license_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.Equal( + new Uri( + "https://api.withorb.com/v1/licenses/license_id/usage?cursor=cursor&end_date=2019-12-27&group_by%5b%5d=string&limit=1&start_date=2019-12-27" + ), + url + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new UsageGetUsageParams + { + LicenseID = "license_id", + Cursor = "cursor", + EndDate = "2019-12-27", + GroupBy = ["string"], + Limit = 1, + StartDate = "2019-12-27", + }; + + UsageGetUsageParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageResponseTest.cs b/src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageResponseTest.cs new file mode 100644 index 000000000..ac5c76362 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageResponseTest.cs @@ -0,0 +1,500 @@ +using System.Collections.Generic; +using System.Text.Json; +using Orb.Core; +using Orb.Models; +using Orb.Models.Licenses.Usage; + +namespace Orb.Tests.Models.Licenses.Usage; + +public class UsageGetUsageResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + List expectedData = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, model.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], model.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, model.PaginationMetadata); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + 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 UsageGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedData = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ]; + PaginationMetadata expectedPaginationMetadata = new() + { + HasMore = true, + NextCursor = "next_cursor", + }; + + Assert.Equal(expectedData.Count, deserialized.Data.Count); + for (int i = 0; i < expectedData.Count; i++) + { + Assert.Equal(expectedData[i], deserialized.Data[i]); + } + Assert.Equal(expectedPaginationMetadata, deserialized.PaginationMetadata); + } + + [Fact] + public void Validation_Works() + { + var model = new UsageGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageGetUsageResponse + { + Data = + [ + new() + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + UsageGetUsageResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UsageGetUsageResponseDataTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + double expectedAllocatedCredits = 0; + double expectedConsumedCredits = 0; + string expectedEndDate = "2019-12-27"; + string expectedLicenseTypeID = "license_type_id"; + string expectedPricingUnit = "pricing_unit"; + double expectedRemainingCredits = 0; + string expectedStartDate = "2019-12-27"; + string expectedSubscriptionID = "subscription_id"; + double expectedAllocationEligibleCredits = 0; + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseID = "license_id"; + double expectedSharedPoolCredits = 0; + + Assert.Equal(expectedAllocatedCredits, model.AllocatedCredits); + Assert.Equal(expectedConsumedCredits, model.ConsumedCredits); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.Equal(expectedPricingUnit, model.PricingUnit); + Assert.Equal(expectedRemainingCredits, model.RemainingCredits); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedSubscriptionID, model.SubscriptionID); + Assert.Equal(expectedAllocationEligibleCredits, model.AllocationEligibleCredits); + Assert.Equal(expectedExternalLicenseID, model.ExternalLicenseID); + Assert.Equal(expectedLicenseID, model.LicenseID); + Assert.Equal(expectedSharedPoolCredits, model.SharedPoolCredits); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 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 UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedAllocatedCredits = 0; + double expectedConsumedCredits = 0; + string expectedEndDate = "2019-12-27"; + string expectedLicenseTypeID = "license_type_id"; + string expectedPricingUnit = "pricing_unit"; + double expectedRemainingCredits = 0; + string expectedStartDate = "2019-12-27"; + string expectedSubscriptionID = "subscription_id"; + double expectedAllocationEligibleCredits = 0; + string expectedExternalLicenseID = "external_license_id"; + string expectedLicenseID = "license_id"; + double expectedSharedPoolCredits = 0; + + Assert.Equal(expectedAllocatedCredits, deserialized.AllocatedCredits); + Assert.Equal(expectedConsumedCredits, deserialized.ConsumedCredits); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.Equal(expectedPricingUnit, deserialized.PricingUnit); + Assert.Equal(expectedRemainingCredits, deserialized.RemainingCredits); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedSubscriptionID, deserialized.SubscriptionID); + Assert.Equal(expectedAllocationEligibleCredits, deserialized.AllocationEligibleCredits); + Assert.Equal(expectedExternalLicenseID, deserialized.ExternalLicenseID); + Assert.Equal(expectedLicenseID, deserialized.LicenseID); + Assert.Equal(expectedSharedPoolCredits, deserialized.SharedPoolCredits); + } + + [Fact] + public void Validation_Works() + { + var model = new UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + }; + + Assert.Null(model.AllocationEligibleCredits); + Assert.False(model.RawData.ContainsKey("allocation_eligible_credits")); + Assert.Null(model.ExternalLicenseID); + Assert.False(model.RawData.ContainsKey("external_license_id")); + Assert.Null(model.LicenseID); + Assert.False(model.RawData.ContainsKey("license_id")); + Assert.Null(model.SharedPoolCredits); + Assert.False(model.RawData.ContainsKey("shared_pool_credits")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + + AllocationEligibleCredits = null, + ExternalLicenseID = null, + LicenseID = null, + SharedPoolCredits = null, + }; + + Assert.Null(model.AllocationEligibleCredits); + Assert.True(model.RawData.ContainsKey("allocation_eligible_credits")); + Assert.Null(model.ExternalLicenseID); + Assert.True(model.RawData.ContainsKey("external_license_id")); + Assert.Null(model.LicenseID); + Assert.True(model.RawData.ContainsKey("license_id")); + Assert.Null(model.SharedPoolCredits); + Assert.True(model.RawData.ContainsKey("shared_pool_credits")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + + AllocationEligibleCredits = null, + ExternalLicenseID = null, + LicenseID = null, + SharedPoolCredits = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageGetUsageResponseData + { + AllocatedCredits = 0, + ConsumedCredits = 0, + EndDate = "2019-12-27", + LicenseTypeID = "license_type_id", + PricingUnit = "pricing_unit", + RemainingCredits = 0, + StartDate = "2019-12-27", + SubscriptionID = "subscription_id", + AllocationEligibleCredits = 0, + ExternalLicenseID = "external_license_id", + LicenseID = "license_id", + SharedPoolCredits = 0, + }; + + UsageGetUsageResponseData copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Services/CreditBlockServiceTest.cs b/src/Orb.Tests/Services/CreditBlockServiceTest.cs index 6fe37fea1..5871f8dda 100644 --- a/src/Orb.Tests/Services/CreditBlockServiceTest.cs +++ b/src/Orb.Tests/Services/CreditBlockServiceTest.cs @@ -24,4 +24,15 @@ await this.client.CreditBlocks.Delete( TestContext.Current.CancellationToken ); } + + [Fact] + public async Task ListInvoices_Works() + { + var response = await this.client.CreditBlocks.ListInvoices( + "block_id", + new(), + TestContext.Current.CancellationToken + ); + response.Validate(); + } } diff --git a/src/Orb.Tests/Services/InvoiceServiceTest.cs b/src/Orb.Tests/Services/InvoiceServiceTest.cs index d4059effa..0863bfa98 100644 --- a/src/Orb.Tests/Services/InvoiceServiceTest.cs +++ b/src/Orb.Tests/Services/InvoiceServiceTest.cs @@ -93,6 +93,17 @@ public async Task Issue_Works() invoice.Validate(); } + [Fact] + public async Task IssueSummary_Works() + { + var response = await this.client.Invoices.IssueSummary( + "invoice_id", + new(), + TestContext.Current.CancellationToken + ); + response.Validate(); + } + [Fact] public async Task ListSummary_Works() { diff --git a/src/Orb.Tests/Services/LicenseServiceTest.cs b/src/Orb.Tests/Services/LicenseServiceTest.cs new file mode 100644 index 000000000..76e2d316f --- /dev/null +++ b/src/Orb.Tests/Services/LicenseServiceTest.cs @@ -0,0 +1,64 @@ +using System.Threading.Tasks; + +namespace Orb.Tests.Services; + +public class LicenseServiceTest : TestBase +{ + [Fact] + public async Task Create_Works() + { + var license = await this.client.Licenses.Create( + new() + { + ExternalLicenseID = "external_license_id", + LicenseTypeID = "license_type_id", + SubscriptionID = "subscription_id", + }, + TestContext.Current.CancellationToken + ); + license.Validate(); + } + + [Fact] + public async Task Retrieve_Works() + { + var license = await this.client.Licenses.Retrieve( + "license_id", + new(), + TestContext.Current.CancellationToken + ); + license.Validate(); + } + + [Fact] + public async Task List_Works() + { + var page = await this.client.Licenses.List( + new() { SubscriptionID = "subscription_id" }, + TestContext.Current.CancellationToken + ); + page.Validate(); + } + + [Fact] + public async Task Deactivate_Works() + { + var response = await this.client.Licenses.Deactivate( + "license_id", + new(), + TestContext.Current.CancellationToken + ); + response.Validate(); + } + + [Fact] + public async Task RetrieveByExternalID_Works() + { + var response = await this.client.Licenses.RetrieveByExternalID( + "external_license_id", + new() { LicenseTypeID = "license_type_id", SubscriptionID = "subscription_id" }, + TestContext.Current.CancellationToken + ); + response.Validate(); + } +} diff --git a/src/Orb.Tests/Services/LicenseTypeServiceTest.cs b/src/Orb.Tests/Services/LicenseTypeServiceTest.cs new file mode 100644 index 000000000..4ebf7197d --- /dev/null +++ b/src/Orb.Tests/Services/LicenseTypeServiceTest.cs @@ -0,0 +1,37 @@ +using System.Threading.Tasks; + +namespace Orb.Tests.Services; + +public class LicenseTypeServiceTest : TestBase +{ + [Fact] + public async Task Create_Works() + { + var licenseType = await this.client.LicenseTypes.Create( + new() { GroupingKey = "grouping_key", Name = "name" }, + TestContext.Current.CancellationToken + ); + licenseType.Validate(); + } + + [Fact] + public async Task Retrieve_Works() + { + var licenseType = await this.client.LicenseTypes.Retrieve( + "license_type_id", + new(), + TestContext.Current.CancellationToken + ); + licenseType.Validate(); + } + + [Fact] + public async Task List_Works() + { + var page = await this.client.LicenseTypes.List( + new(), + TestContext.Current.CancellationToken + ); + page.Validate(); + } +} diff --git a/src/Orb.Tests/Services/Licenses/ExternalLicenseServiceTest.cs b/src/Orb.Tests/Services/Licenses/ExternalLicenseServiceTest.cs new file mode 100644 index 000000000..a3da4d5f3 --- /dev/null +++ b/src/Orb.Tests/Services/Licenses/ExternalLicenseServiceTest.cs @@ -0,0 +1,17 @@ +using System.Threading.Tasks; + +namespace Orb.Tests.Services.Licenses; + +public class ExternalLicenseServiceTest : TestBase +{ + [Fact] + public async Task GetUsage_Works() + { + var response = await this.client.Licenses.ExternalLicenses.GetUsage( + "external_license_id", + new() { LicenseTypeID = "license_type_id", SubscriptionID = "subscription_id" }, + TestContext.Current.CancellationToken + ); + response.Validate(); + } +} diff --git a/src/Orb.Tests/Services/Licenses/UsageServiceTest.cs b/src/Orb.Tests/Services/Licenses/UsageServiceTest.cs new file mode 100644 index 000000000..e0919a0e4 --- /dev/null +++ b/src/Orb.Tests/Services/Licenses/UsageServiceTest.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; + +namespace Orb.Tests.Services.Licenses; + +public class UsageServiceTest : TestBase +{ + [Fact] + public async Task GetAllUsage_Works() + { + var response = await this.client.Licenses.Usage.GetAllUsage( + new() { LicenseTypeID = "license_type_id", SubscriptionID = "subscription_id" }, + TestContext.Current.CancellationToken + ); + response.Validate(); + } + + [Fact] + public async Task GetUsage_Works() + { + var response = await this.client.Licenses.Usage.GetUsage( + "license_id", + new(), + TestContext.Current.CancellationToken + ); + response.Validate(); + } +} diff --git a/src/Orb/Core/ModelBase.cs b/src/Orb/Core/ModelBase.cs index cf069d55d..2ebc67343 100644 --- a/src/Orb/Core/ModelBase.cs +++ b/src/Orb/Core/ModelBase.cs @@ -15,6 +15,7 @@ using ExternalPlanID = Orb.Models.Beta.ExternalPlanID; using Invoices = Orb.Models.Invoices; using Ledger = Orb.Models.Customers.Credits.Ledger; +using Licenses = Orb.Models.Licenses; using Metrics = Orb.Models.Metrics; using Migrations = Orb.Models.Plans.Migrations; using Plans = Orb.Models.Plans; @@ -560,6 +561,20 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter< + string, + Invoices::InvoiceIssueSummaryResponseCustomerBalanceTransactionAction + >(), + new ApiEnumConverter< + string, + Invoices::InvoiceIssueSummaryResponseCustomerBalanceTransactionType + >(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Invoices::InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider + >(), + new ApiEnumConverter(), new ApiEnumConverter< string, Invoices::InvoiceListSummaryResponseCustomerBalanceTransactionAction @@ -926,6 +941,16 @@ 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(), }, }; diff --git a/src/Orb/IOrbClient.cs b/src/Orb/IOrbClient.cs index 89da21268..74725d146 100644 --- a/src/Orb/IOrbClient.cs +++ b/src/Orb/IOrbClient.cs @@ -86,6 +86,10 @@ public interface IOrbClient : IDisposable ISubscriptionChangeService SubscriptionChanges { get; } ICreditBlockService CreditBlocks { get; } + + ILicenseTypeService LicenseTypes { get; } + + ILicenseService Licenses { get; } } /// @@ -153,6 +157,10 @@ public interface IOrbClientWithRawResponse : IDisposable ICreditBlockServiceWithRawResponse CreditBlocks { get; } + ILicenseTypeServiceWithRawResponse LicenseTypes { get; } + + ILicenseServiceWithRawResponse Licenses { get; } + /// /// Sends a request to the Orb REST API. /// diff --git a/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs new file mode 100644 index 000000000..c155b5276 --- /dev/null +++ b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.CreditBlocks; + +/// +/// This endpoint returns the credit block and its associated purchasing invoices. +/// +/// If a credit block was purchased (as opposed to being manually added or allocated +/// from a subscription), this endpoint returns the invoices that were created to +/// charge the customer for the credit block. For credit blocks with payment schedules +/// spanning multiple periods (e.g., monthly payments over 12 months), multiple invoices +/// will be returned. +/// +/// If the credit block was not purchased (e.g., manual increment, allocation), +/// an empty invoices list is returned. +/// +/// **Note: This endpoint is currently experimental and its interface may change +/// in future releases. Please contact support before building production integrations +/// against 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 record class CreditBlockListInvoicesParams : ParamsBase +{ + public string? BlockID { get; init; } + + public CreditBlockListInvoicesParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CreditBlockListInvoicesParams( + CreditBlockListInvoicesParams creditBlockListInvoicesParams + ) + : base(creditBlockListInvoicesParams) + { + this.BlockID = creditBlockListInvoicesParams.BlockID; + } +#pragma warning restore CS8618 + + public CreditBlockListInvoicesParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CreditBlockListInvoicesParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static CreditBlockListInvoicesParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(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(CreditBlockListInvoicesParams? 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( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/credit_blocks/{0}/invoices", this.BlockID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesResponse.cs b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesResponse.cs new file mode 100644 index 000000000..fe0cbdb09 --- /dev/null +++ b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesResponse.cs @@ -0,0 +1,653 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.CreditBlocks; + +[JsonConverter( + typeof(JsonModelConverter< + CreditBlockListInvoicesResponse, + CreditBlockListInvoicesResponseFromRaw + >) +)] +public sealed record class CreditBlockListInvoicesResponse : JsonModel +{ + /// + /// The Credit Block resource models prepaid credits within Orb. + /// + public required Block Block + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("block"); + } + init { this._rawData.Set("block", value); } + } + + public required IReadOnlyList Invoices + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("invoices"); + } + init + { + this._rawData.Set>( + "invoices", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + this.Block.Validate(); + foreach (var item in this.Invoices) + { + item.Validate(); + } + } + + public CreditBlockListInvoicesResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CreditBlockListInvoicesResponse( + CreditBlockListInvoicesResponse creditBlockListInvoicesResponse + ) + : base(creditBlockListInvoicesResponse) { } +#pragma warning restore CS8618 + + public CreditBlockListInvoicesResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CreditBlockListInvoicesResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CreditBlockListInvoicesResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CreditBlockListInvoicesResponseFromRaw : IFromRawJson +{ + /// + public CreditBlockListInvoicesResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CreditBlockListInvoicesResponse.FromRawUnchecked(rawData); +} + +/// +/// The Credit Block resource models prepaid credits within Orb. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Block : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required double Balance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("balance"); + } + init { this._rawData.Set("balance", value); } + } + + public required System::DateTimeOffset? EffectiveDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("effective_date"); + } + init { this._rawData.Set("effective_date", value); } + } + + public required System::DateTimeOffset? ExpiryDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("expiry_date"); + } + init { this._rawData.Set("expiry_date", value); } + } + + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("filters"); + } + init + { + this._rawData.Set>( + "filters", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required double? MaximumInitialBalance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("maximum_initial_balance"); + } + init { this._rawData.Set("maximum_initial_balance", 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) + ); + } + } + + public required string? PerUnitCostBasis + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("per_unit_cost_basis"); + } + init { this._rawData.Set("per_unit_cost_basis", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("status"); + } + init { this._rawData.Set("status", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Balance; + _ = this.EffectiveDate; + _ = this.ExpiryDate; + foreach (var item in this.Filters) + { + item.Validate(); + } + _ = this.MaximumInitialBalance; + _ = this.Metadata; + _ = this.PerUnitCostBasis; + this.Status.Validate(); + } + + public Block() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Block(Block block) + : base(block) { } +#pragma warning restore CS8618 + + public Block(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Block(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Block FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BlockFromRaw : IFromRawJson +{ + /// + public Block FromRawUnchecked(IReadOnlyDictionary rawData) => + Block.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BlockFilter : JsonModel +{ + /// + /// The property of the price to filter on. + /// + public required ApiEnum Field + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("field"); + } + init { this._rawData.Set("field", value); } + } + + /// + /// Should prices that match the filter be included or excluded. + /// + public required ApiEnum Operator + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("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 BlockFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BlockFilter(BlockFilter blockFilter) + : base(blockFilter) { } +#pragma warning restore CS8618 + + public BlockFilter(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BlockFilter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BlockFilter FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BlockFilterFromRaw : IFromRawJson +{ + /// + public BlockFilter FromRawUnchecked(IReadOnlyDictionary rawData) => + BlockFilter.FromRawUnchecked(rawData); +} + +/// +/// The property of the price to filter on. +/// +[JsonConverter(typeof(BlockFilterFieldConverter))] +public enum BlockFilterField +{ + PriceID, + ItemID, + PriceType, + Currency, + PricingUnitID, +} + +sealed class BlockFilterFieldConverter : JsonConverter +{ + public override BlockFilterField Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "price_id" => BlockFilterField.PriceID, + "item_id" => BlockFilterField.ItemID, + "price_type" => BlockFilterField.PriceType, + "currency" => BlockFilterField.Currency, + "pricing_unit_id" => BlockFilterField.PricingUnitID, + _ => (BlockFilterField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BlockFilterField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BlockFilterField.PriceID => "price_id", + BlockFilterField.ItemID => "item_id", + BlockFilterField.PriceType => "price_type", + BlockFilterField.Currency => "currency", + BlockFilterField.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(BlockFilterOperatorConverter))] +public enum BlockFilterOperator +{ + Includes, + Excludes, +} + +sealed class BlockFilterOperatorConverter : JsonConverter +{ + public override BlockFilterOperator Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "includes" => BlockFilterOperator.Includes, + "excludes" => BlockFilterOperator.Excludes, + _ => (BlockFilterOperator)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BlockFilterOperator value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BlockFilterOperator.Includes => "includes", + BlockFilterOperator.Excludes => "excludes", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(BlockStatusConverter))] +public enum BlockStatus +{ + Active, + PendingPayment, +} + +sealed class BlockStatusConverter : JsonConverter +{ + public override BlockStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => BlockStatus.Active, + "pending_payment" => BlockStatus.PendingPayment, + _ => (BlockStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BlockStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BlockStatus.Active => "active", + BlockStatus.PendingPayment => "pending_payment", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Invoice : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required CustomerMinified Customer + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("customer"); + } + init { this._rawData.Set("customer", value); } + } + + public required string InvoiceNumber + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("invoice_number"); + } + init { this._rawData.Set("invoice_number", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("status"); + } + init { this._rawData.Set("status", value); } + } + + public required SubscriptionMinified? Subscription + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("subscription"); + } + init { this._rawData.Set("subscription", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + this.Customer.Validate(); + _ = this.InvoiceNumber; + this.Status.Validate(); + this.Subscription?.Validate(); + } + + public Invoice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Invoice(Invoice invoice) + : base(invoice) { } +#pragma warning restore CS8618 + + public Invoice(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Invoice(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Invoice FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceFromRaw : IFromRawJson +{ + /// + public Invoice FromRawUnchecked(IReadOnlyDictionary rawData) => + Invoice.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(InvoiceStatusConverter))] +public enum InvoiceStatus +{ + Issued, + Paid, + Synced, + Void, + Draft, +} + +sealed class InvoiceStatusConverter : JsonConverter +{ + public override InvoiceStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "issued" => InvoiceStatus.Issued, + "paid" => InvoiceStatus.Paid, + "synced" => InvoiceStatus.Synced, + "void" => InvoiceStatus.Void, + "draft" => InvoiceStatus.Draft, + _ => (InvoiceStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceStatus.Issued => "issued", + InvoiceStatus.Paid => "paid", + InvoiceStatus.Synced => "synced", + InvoiceStatus.Void => "void", + InvoiceStatus.Draft => "draft", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs new file mode 100644 index 000000000..7037cad33 --- /dev/null +++ b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Invoices; + +/// +/// This endpoint allows an eligible invoice to be issued manually. This is only possible +/// with invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` +/// 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). +/// +/// This is a lighter-weight alternative to the issue invoice endpoint, returning +/// an invoice summary without any line item details. +/// +/// 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 record class InvoiceIssueSummaryParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? InvoiceID { get; init; } + + /// + /// If true, the invoice will be issued synchronously. If false, the invoice + /// will be issued asynchronously. The synchronous option is only available for + /// invoices that have no usage fees. If the invoice is configured to sync to + /// an external provider, a successful response from this endpoint guarantees + /// the invoice is present in the provider. + /// + public bool? Synchronous + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("synchronous"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("synchronous", value); + } + } + + public InvoiceIssueSummaryParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryParams(InvoiceIssueSummaryParams invoiceIssueSummaryParams) + : base(invoiceIssueSummaryParams) + { + this.InvoiceID = invoiceIssueSummaryParams.InvoiceID; + + this._rawBodyData = new(invoiceIssueSummaryParams._rawBodyData); + } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(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(InvoiceIssueSummaryParams? 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( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/invoices/summary/{0}/issue", this.InvoiceID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Invoices/InvoiceIssueSummaryResponse.cs b/src/Orb/Models/Invoices/InvoiceIssueSummaryResponse.cs new file mode 100644 index 000000000..f0b644e68 --- /dev/null +++ b/src/Orb/Models/Invoices/InvoiceIssueSummaryResponse.cs @@ -0,0 +1,1559 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Invoices; + +/// +/// #InvoiceApiResourceWithoutLineItems +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class InvoiceIssueSummaryResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// This is the final amount required to be charged to the customer and reflects + /// the application of the customer balance to the `total` of the invoice. + /// + public required string AmountDue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount_due"); + } + init { this._rawData.Set("amount_due", value); } + } + + public required InvoiceIssueSummaryResponseAutoCollection AutoCollection + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "auto_collection" + ); + } + init { this._rawData.Set("auto_collection", value); } + } + + public required Address? BillingAddress + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass
("billing_address"); + } + init { this._rawData.Set("billing_address", value); } + } + + /// + /// The creation time of the resource in Orb. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// A list of credit notes associated with the invoice + /// + public required IReadOnlyList CreditNotes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("credit_notes"); + } + init + { + this._rawData.Set>( + "credit_notes", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// An ISO 4217 currency string or `credits` + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + public required CustomerMinified Customer + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("customer"); + } + init { this._rawData.Set("customer", value); } + } + + public required IReadOnlyList CustomerBalanceTransactions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("customer_balance_transactions"); + } + init + { + this._rawData.Set< + ImmutableArray + >("customer_balance_transactions", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Tax IDs are commonly required to be displayed on customer invoices, which + /// are added to the headers of invoices. + /// + /// ### Supported Tax ID Countries and Types + /// + /// | Country | Type | Description | |---------|------|-------------| | + /// Albania | `al_tin` | Albania Tax Identification Number | | Andorra | `ad_nrt` + /// | Andorran NRT Number | | Angola | `ao_tin` | Angola Tax Identification Number + /// | | Argentina | `ar_cuit` | Argentinian Tax ID Number | | Armenia | `am_tin` + /// | Armenia Tax Identification Number | | Aruba | `aw_tin` | Aruba Tax Identification + /// Number | | Australia | `au_abn` | Australian Business Number (AU ABN) | | + /// Australia | `au_arn` | Australian Taxation Office Reference Number | | Austria + /// | `eu_vat` | European VAT Number | | Azerbaijan | `az_tin` | Azerbaijan Tax + /// Identification Number | | Bahamas | `bs_tin` | Bahamas Tax Identification + /// Number | | Bahrain | `bh_vat` | Bahraini VAT Number | | Bangladesh | `bd_bin` + /// | Bangladesh Business Identification Number | | Barbados | `bb_tin` | Barbados + /// Tax Identification Number | | Belarus | `by_tin` | Belarus TIN Number | | + /// Belgium | `eu_vat` | European VAT Number | | Benin | `bj_ifu` | Benin Tax + /// Identification Number (Identifiant Fiscal Unique) | | Bolivia | `bo_tin` + /// | Bolivian Tax ID | | Bosnia and Herzegovina | `ba_tin` | Bosnia and Herzegovina + /// Tax Identification Number | | Brazil | `br_cnpj` | Brazilian CNPJ Number | + /// | Brazil | `br_cpf` | Brazilian CPF Number | | Bulgaria | `bg_uic` | Bulgaria + /// Unified Identification Code | | Bulgaria | `eu_vat` | European VAT Number + /// | | Burkina Faso | `bf_ifu` | Burkina Faso Tax Identification Number (Numéro + /// d'Identifiant Fiscal Unique) | | Cambodia | `kh_tin` | Cambodia Tax Identification + /// Number | | Cameroon | `cm_niu` | Cameroon Tax Identification Number (Numéro + /// d'Identifiant fiscal Unique) | | Canada | `ca_bn` | Canadian BN | | Canada + /// | `ca_gst_hst` | Canadian GST/HST Number | | Canada | `ca_pst_bc` | Canadian + /// PST Number (British Columbia) | | Canada | `ca_pst_mb` | Canadian PST Number + /// (Manitoba) | | Canada | `ca_pst_sk` | Canadian PST Number (Saskatchewan) | + /// | Canada | `ca_qst` | Canadian QST Number (Québec) | | Cape Verde | `cv_nif` + /// | Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + /// | Chile | `cl_tin` | Chilean TIN | | China | `cn_tin` | Chinese Tax ID | | + /// Colombia | `co_nit` | Colombian NIT Number | | Congo-Kinshasa | `cd_nif` + /// | Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + /// | Costa Rica | `cr_tin` | Costa Rican Tax ID | | Croatia | `eu_vat` | European + /// VAT Number | | Croatia | `hr_oib` | Croatian Personal Identification Number + /// (OIB) | | Cyprus | `eu_vat` | European VAT Number | | Czech Republic | `eu_vat` + /// | European VAT Number | | Denmark | `eu_vat` | European VAT Number | | Dominican + /// Republic | `do_rcn` | Dominican RCN Number | | Ecuador | `ec_ruc` | Ecuadorian + /// RUC Number | | Egypt | `eg_tin` | Egyptian Tax Identification Number | | + /// El Salvador | `sv_nit` | El Salvadorian NIT Number | | Estonia | `eu_vat` + /// | European VAT Number | | Ethiopia | `et_tin` | Ethiopia Tax Identification + /// Number | | European Union | `eu_oss_vat` | European One Stop Shop VAT Number + /// for non-Union scheme | | Finland | `eu_vat` | European VAT Number | | France + /// | `eu_vat` | European VAT Number | | Georgia | `ge_vat` | Georgian VAT | | + /// Germany | `de_stn` | German Tax Number (Steuernummer) | | Germany | `eu_vat` + /// | European VAT Number | | Greece | `eu_vat` | European VAT Number | | Guinea + /// | `gn_nif` | Guinea Tax Identification Number (Número de Identificação Fiscal) + /// | | Hong Kong | `hk_br` | Hong Kong BR Number | | Hungary | `eu_vat` | European + /// VAT Number | | Hungary | `hu_tin` | Hungary Tax Number (adószám) | | Iceland + /// | `is_vat` | Icelandic VAT | | India | `in_gst` | Indian GST Number | | Indonesia + /// | `id_npwp` | Indonesian NPWP Number | | Ireland | `eu_vat` | European VAT + /// Number | | Israel | `il_vat` | Israel VAT | | Italy | `eu_vat` | European + /// VAT Number | | Japan | `jp_cn` | Japanese Corporate Number (*Hōjin Bangō*) + /// | | Japan | `jp_rn` | Japanese Registered Foreign Businesses' Registration + /// Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*) | | Japan | `jp_trn` | + /// Japanese Tax Registration Number (*Tōroku Bangō*) | | Kazakhstan | `kz_bin` + /// | Kazakhstani Business Identification Number | | Kenya | `ke_pin` | Kenya + /// Revenue Authority Personal Identification Number | | Kyrgyzstan | `kg_tin` + /// | Kyrgyzstan Tax Identification Number | | Laos | `la_tin` | Laos Tax Identification + /// Number | | Latvia | `eu_vat` | European VAT Number | | Liechtenstein | `li_uid` + /// | Liechtensteinian UID Number | | Liechtenstein | `li_vat` | Liechtenstein + /// VAT Number | | Lithuania | `eu_vat` | European VAT Number | | Luxembourg + /// | `eu_vat` | European VAT Number | | Malaysia | `my_frp` | Malaysian FRP + /// Number | | Malaysia | `my_itn` | Malaysian ITN | | Malaysia | `my_sst` | Malaysian + /// SST Number | | Malta | `eu_vat` | European VAT Number | | Mauritania | `mr_nif` + /// | Mauritania Tax Identification Number (Número de Identificação Fiscal) | + /// | Mexico | `mx_rfc` | Mexican RFC Number | | Moldova | `md_vat` | Moldova + /// VAT Number | | Montenegro | `me_pib` | Montenegro PIB Number | | Morocco | + /// `ma_vat` | Morocco VAT Number | | Nepal | `np_pan` | Nepal PAN Number | | + /// Netherlands | `eu_vat` | European VAT Number | | New Zealand | `nz_gst` | + /// New Zealand GST Number | | Nigeria | `ng_tin` | Nigerian Tax Identification + /// Number | | North Macedonia | `mk_vat` | North Macedonia VAT Number | | Northern + /// Ireland | `eu_vat` | Northern Ireland VAT Number | | Norway | `no_vat` | + /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce + /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian + /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | + /// + public required CustomerTaxID? CustomerTaxID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("customer_tax_id"); + } + init { this._rawData.Set("customer_tax_id", value); } + } + + /// + /// When the invoice payment is due. The due date is null if the invoice is not + /// yet finalized. + /// + public required System::DateTimeOffset? DueDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("due_date"); + } + init { this._rawData.Set("due_date", value); } + } + + /// + /// If the invoice has a status of `draft`, this will be the time that the invoice + /// will be eligible to be issued, otherwise it will be `null`. If `auto-issue` + /// is true, the invoice will automatically begin issuing at this time. + /// + public required System::DateTimeOffset? EligibleToIssueAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("eligible_to_issue_at"); + } + init { this._rawData.Set("eligible_to_issue_at", value); } + } + + /// + /// A URL for the customer-facing invoice portal. This URL expires 30 days after + /// the invoice's due date, or 60 days after being re-generated through the UI. + /// + public required string? HostedInvoiceUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("hosted_invoice_url"); + } + init { this._rawData.Set("hosted_invoice_url", value); } + } + + /// + /// The scheduled date of the invoice + /// + public required System::DateTimeOffset InvoiceDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("invoice_date"); + } + init { this._rawData.Set("invoice_date", value); } + } + + /// + /// Automatically generated invoice number to help track and reconcile invoices. + /// Invoice numbers have a prefix such as `RFOBWG`. These can be sequential per + /// account or customer. + /// + public required string InvoiceNumber + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("invoice_number"); + } + init { this._rawData.Set("invoice_number", value); } + } + + /// + /// The link to download the PDF representation of the `Invoice`. + /// + public required string? InvoicePdf + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_pdf"); + } + init { this._rawData.Set("invoice_pdf", value); } + } + + public required ApiEnum InvoiceSource + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("invoice_source"); + } + init { this._rawData.Set("invoice_source", value); } + } + + /// + /// If the invoice failed to issue, this will be the last time it failed to issue + /// (even if it is now in a different state.) + /// + public required System::DateTimeOffset? IssueFailedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("issue_failed_at"); + } + init { this._rawData.Set("issue_failed_at", value); } + } + + /// + /// If the invoice has been issued, this will be the time it transitioned to + /// `issued` (even if it is now in a different state.) + /// + public required System::DateTimeOffset? IssuedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("issued_at"); + } + init { this._rawData.Set("issued_at", value); } + } + + /// + /// Free-form text which is available on the invoice PDF and the Orb invoice portal. + /// + public required string? Memo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("memo"); + } + init { this._rawData.Set("memo", 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) + ); + } + } + + /// + /// If the invoice has a status of `paid`, this gives a timestamp when the invoice + /// was paid. + /// + public required System::DateTimeOffset? PaidAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("paid_at"); + } + init { this._rawData.Set("paid_at", value); } + } + + /// + /// A list of payment attempts associated with the invoice + /// + public required IReadOnlyList PaymentAttempts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("payment_attempts"); + } + init + { + this._rawData.Set>( + "payment_attempts", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// If payment was attempted on this invoice but failed, this will be the time + /// of the most recent attempt. + /// + public required System::DateTimeOffset? PaymentFailedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("payment_failed_at"); + } + init { this._rawData.Set("payment_failed_at", value); } + } + + /// + /// If payment was attempted on this invoice, this will be the start time of + /// the most recent attempt. This field is especially useful for delayed-notification + /// payment mechanisms (like bank transfers), where payment can take 3 days or more. + /// + public required System::DateTimeOffset? PaymentStartedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("payment_started_at"); + } + init { this._rawData.Set("payment_started_at", value); } + } + + /// + /// If the invoice is in draft, this timestamp will reflect when the invoice is + /// scheduled to be issued. + /// + public required System::DateTimeOffset? ScheduledIssueAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("scheduled_issue_at"); + } + init { this._rawData.Set("scheduled_issue_at", value); } + } + + public required Address? ShippingAddress + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass
("shipping_address"); + } + init { this._rawData.Set("shipping_address", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("status"); + } + init { this._rawData.Set("status", value); } + } + + public required SubscriptionMinified? Subscription + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("subscription"); + } + init { this._rawData.Set("subscription", value); } + } + + /// + /// If the invoice failed to sync, this will be the last time an external invoicing + /// provider sync was attempted. This field will always be `null` for invoices + /// using Orb Invoicing. + /// + public required System::DateTimeOffset? SyncFailedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("sync_failed_at"); + } + init { this._rawData.Set("sync_failed_at", value); } + } + + /// + /// The total after any minimums and discounts have been applied. + /// + public required string Total + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total"); + } + init { this._rawData.Set("total", value); } + } + + /// + /// If the invoice has a status of `void`, this gives a timestamp when the invoice + /// was voided. + /// + public required System::DateTimeOffset? VoidedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("voided_at"); + } + init { this._rawData.Set("voided_at", value); } + } + + /// + /// This is true if the invoice will be automatically issued in the future, and + /// false otherwise. + /// + public required bool WillAutoIssue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("will_auto_issue"); + } + init { this._rawData.Set("will_auto_issue", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.AmountDue; + this.AutoCollection.Validate(); + this.BillingAddress?.Validate(); + _ = this.CreatedAt; + foreach (var item in this.CreditNotes) + { + item.Validate(); + } + _ = this.Currency; + this.Customer.Validate(); + foreach (var item in this.CustomerBalanceTransactions) + { + item.Validate(); + } + this.CustomerTaxID?.Validate(); + _ = this.DueDate; + _ = this.EligibleToIssueAt; + _ = this.HostedInvoiceUrl; + _ = this.InvoiceDate; + _ = this.InvoiceNumber; + _ = this.InvoicePdf; + this.InvoiceSource.Validate(); + _ = this.IssueFailedAt; + _ = this.IssuedAt; + _ = this.Memo; + _ = this.Metadata; + _ = this.PaidAt; + foreach (var item in this.PaymentAttempts) + { + item.Validate(); + } + _ = this.PaymentFailedAt; + _ = this.PaymentStartedAt; + _ = this.ScheduledIssueAt; + this.ShippingAddress?.Validate(); + this.Status.Validate(); + this.Subscription?.Validate(); + _ = this.SyncFailedAt; + _ = this.Total; + _ = this.VoidedAt; + _ = this.WillAutoIssue; + } + + public InvoiceIssueSummaryResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponse(InvoiceIssueSummaryResponse invoiceIssueSummaryResponse) + : base(invoiceIssueSummaryResponse) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponseFromRaw : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponse.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + InvoiceIssueSummaryResponseAutoCollection, + InvoiceIssueSummaryResponseAutoCollectionFromRaw + >) +)] +public sealed record class InvoiceIssueSummaryResponseAutoCollection : JsonModel +{ + /// + /// True only if auto-collection is enabled for this invoice. + /// + public required bool? Enabled + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("enabled"); + } + init { this._rawData.Set("enabled", value); } + } + + /// + /// If the invoice is scheduled for auto-collection, this field will reflect when + /// the next attempt will occur. If dunning has been exhausted, or auto-collection + /// is not enabled for this invoice, this field will be `null`. + /// + public required System::DateTimeOffset? NextAttemptAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("next_attempt_at"); + } + init { this._rawData.Set("next_attempt_at", value); } + } + + /// + /// Number of auto-collection payment attempts. + /// + public required long? NumAttempts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("num_attempts"); + } + init { this._rawData.Set("num_attempts", value); } + } + + /// + /// If Orb has ever attempted payment auto-collection for this invoice, this field + /// will reflect when that attempt occurred. In conjunction with `next_attempt_at`, + /// this can be used to tell whether the invoice is currently in dunning (that + /// is, `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), + /// or if dunning has been exhausted (`previously_attempted_at` is non-null, but + /// `next_attempt_time` is null). + /// + public required System::DateTimeOffset? PreviouslyAttemptedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct( + "previously_attempted_at" + ); + } + init { this._rawData.Set("previously_attempted_at", value); } + } + + /// + public override void Validate() + { + _ = this.Enabled; + _ = this.NextAttemptAt; + _ = this.NumAttempts; + _ = this.PreviouslyAttemptedAt; + } + + public InvoiceIssueSummaryResponseAutoCollection() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponseAutoCollection( + InvoiceIssueSummaryResponseAutoCollection invoiceIssueSummaryResponseAutoCollection + ) + : base(invoiceIssueSummaryResponseAutoCollection) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponseAutoCollection( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponseAutoCollection(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponseAutoCollection FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponseAutoCollectionFromRaw + : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponseAutoCollection FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponseAutoCollection.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + InvoiceIssueSummaryResponseCreditNote, + InvoiceIssueSummaryResponseCreditNoteFromRaw + >) +)] +public sealed record class InvoiceIssueSummaryResponseCreditNote : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required string CreditNoteNumber + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("credit_note_number"); + } + init { this._rawData.Set("credit_note_number", value); } + } + + /// + /// An optional memo supplied on the credit note. + /// + public required string? Memo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("memo"); + } + init { this._rawData.Set("memo", value); } + } + + public required string Reason + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("reason"); + } + init { this._rawData.Set("reason", value); } + } + + public required string Total + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total"); + } + init { this._rawData.Set("total", value); } + } + + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// If the credit note has a status of `void`, this gives a timestamp when the + /// credit note was voided. + /// + public required System::DateTimeOffset? VoidedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("voided_at"); + } + init { this._rawData.Set("voided_at", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.CreditNoteNumber; + _ = this.Memo; + _ = this.Reason; + _ = this.Total; + _ = this.Type; + _ = this.VoidedAt; + } + + public InvoiceIssueSummaryResponseCreditNote() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponseCreditNote( + InvoiceIssueSummaryResponseCreditNote invoiceIssueSummaryResponseCreditNote + ) + : base(invoiceIssueSummaryResponseCreditNote) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponseCreditNote(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponseCreditNote(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponseCreditNote FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponseCreditNoteFromRaw + : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponseCreditNote FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponseCreditNote.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + InvoiceIssueSummaryResponseCustomerBalanceTransaction, + InvoiceIssueSummaryResponseCustomerBalanceTransactionFromRaw + >) +)] +public sealed record class InvoiceIssueSummaryResponseCustomerBalanceTransaction : JsonModel +{ + /// + /// A unique id for this transaction. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required ApiEnum< + string, + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction + > Action + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("action"); + } + init { this._rawData.Set("action", value); } + } + + /// + /// The value of the amount changed in the transaction. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The creation time of this transaction. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required CreditNoteTiny? CreditNote + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("credit_note"); + } + init { this._rawData.Set("credit_note", value); } + } + + /// + /// An optional description provided for manual customer balance adjustments. + /// + public required string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + /// The new value of the customer's balance prior to the transaction, in the customer's currency. + /// + public required string EndingBalance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("ending_balance"); + } + init { this._rawData.Set("ending_balance", value); } + } + + public required InvoiceTiny? Invoice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice"); + } + init { this._rawData.Set("invoice", value); } + } + + /// + /// The original value of the customer's balance prior to the transaction, in + /// the customer's currency. + /// + public required string StartingBalance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("starting_balance"); + } + init { this._rawData.Set("starting_balance", value); } + } + + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + this.Action.Validate(); + _ = this.Amount; + _ = this.CreatedAt; + this.CreditNote?.Validate(); + _ = this.Description; + _ = this.EndingBalance; + this.Invoice?.Validate(); + _ = this.StartingBalance; + this.Type.Validate(); + } + + public InvoiceIssueSummaryResponseCustomerBalanceTransaction() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponseCustomerBalanceTransaction( + InvoiceIssueSummaryResponseCustomerBalanceTransaction invoiceIssueSummaryResponseCustomerBalanceTransaction + ) + : base(invoiceIssueSummaryResponseCustomerBalanceTransaction) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponseCustomerBalanceTransaction( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponseCustomerBalanceTransaction( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponseCustomerBalanceTransaction FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponseCustomerBalanceTransactionFromRaw + : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponseCustomerBalanceTransaction FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponseCustomerBalanceTransaction.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(InvoiceIssueSummaryResponseCustomerBalanceTransactionActionConverter))] +public enum InvoiceIssueSummaryResponseCustomerBalanceTransactionAction +{ + AppliedToInvoice, + ManualAdjustment, + ProratedRefund, + RevertProratedRefund, + ReturnFromVoiding, + CreditNoteApplied, + CreditNoteVoided, + OverpaymentRefund, + ExternalPayment, + SmallInvoiceCarryover, +} + +sealed class InvoiceIssueSummaryResponseCustomerBalanceTransactionActionConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponseCustomerBalanceTransactionAction Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "applied_to_invoice" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + "manual_adjustment" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ManualAdjustment, + "prorated_refund" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ProratedRefund, + "revert_prorated_refund" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.RevertProratedRefund, + "return_from_voiding" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ReturnFromVoiding, + "credit_note_applied" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteApplied, + "credit_note_voided" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteVoided, + "overpayment_refund" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.OverpaymentRefund, + "external_payment" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ExternalPayment, + "small_invoice_carryover" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.SmallInvoiceCarryover, + _ => (InvoiceIssueSummaryResponseCustomerBalanceTransactionAction)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice => + "applied_to_invoice", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ManualAdjustment => + "manual_adjustment", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ProratedRefund => + "prorated_refund", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.RevertProratedRefund => + "revert_prorated_refund", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ReturnFromVoiding => + "return_from_voiding", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteApplied => + "credit_note_applied", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteVoided => + "credit_note_voided", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.OverpaymentRefund => + "overpayment_refund", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ExternalPayment => + "external_payment", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.SmallInvoiceCarryover => + "small_invoice_carryover", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(InvoiceIssueSummaryResponseCustomerBalanceTransactionTypeConverter))] +public enum InvoiceIssueSummaryResponseCustomerBalanceTransactionType +{ + Increment, + Decrement, +} + +sealed class InvoiceIssueSummaryResponseCustomerBalanceTransactionTypeConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponseCustomerBalanceTransactionType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "increment" => InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + "decrement" => InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Decrement, + _ => (InvoiceIssueSummaryResponseCustomerBalanceTransactionType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponseCustomerBalanceTransactionType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment => "increment", + InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Decrement => "decrement", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(InvoiceIssueSummaryResponseInvoiceSourceConverter))] +public enum InvoiceIssueSummaryResponseInvoiceSource +{ + Subscription, + Partial, + OneOff, +} + +sealed class InvoiceIssueSummaryResponseInvoiceSourceConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponseInvoiceSource Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "subscription" => InvoiceIssueSummaryResponseInvoiceSource.Subscription, + "partial" => InvoiceIssueSummaryResponseInvoiceSource.Partial, + "one_off" => InvoiceIssueSummaryResponseInvoiceSource.OneOff, + _ => (InvoiceIssueSummaryResponseInvoiceSource)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponseInvoiceSource value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponseInvoiceSource.Subscription => "subscription", + InvoiceIssueSummaryResponseInvoiceSource.Partial => "partial", + InvoiceIssueSummaryResponseInvoiceSource.OneOff => "one_off", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + InvoiceIssueSummaryResponsePaymentAttempt, + InvoiceIssueSummaryResponsePaymentAttemptFromRaw + >) +)] +public sealed record class InvoiceIssueSummaryResponsePaymentAttempt : JsonModel +{ + /// + /// The ID of the payment attempt. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The amount of the payment attempt. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The time at which the payment attempt was created. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// The payment provider that attempted to collect the payment. + /// + public required ApiEnum< + string, + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider + >? PaymentProvider + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("payment_provider"); + } + init { this._rawData.Set("payment_provider", value); } + } + + /// + /// The ID of the payment attempt in the payment provider. + /// + public required string? PaymentProviderID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("payment_provider_id"); + } + init { this._rawData.Set("payment_provider_id", value); } + } + + /// + /// URL to the downloadable PDF version of the receipt. This field will be `null` + /// for payment attempts that did not succeed. + /// + public required string? ReceiptPdf + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("receipt_pdf"); + } + init { this._rawData.Set("receipt_pdf", value); } + } + + /// + /// Whether the payment attempt succeeded. + /// + public required bool Succeeded + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("succeeded"); + } + init { this._rawData.Set("succeeded", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Amount; + _ = this.CreatedAt; + this.PaymentProvider?.Validate(); + _ = this.PaymentProviderID; + _ = this.ReceiptPdf; + _ = this.Succeeded; + } + + public InvoiceIssueSummaryResponsePaymentAttempt() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponsePaymentAttempt( + InvoiceIssueSummaryResponsePaymentAttempt invoiceIssueSummaryResponsePaymentAttempt + ) + : base(invoiceIssueSummaryResponsePaymentAttempt) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponsePaymentAttempt( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponsePaymentAttempt(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponsePaymentAttempt FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponsePaymentAttemptFromRaw + : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponsePaymentAttempt FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponsePaymentAttempt.FromRawUnchecked(rawData); +} + +/// +/// The payment provider that attempted to collect the payment. +/// +[JsonConverter(typeof(InvoiceIssueSummaryResponsePaymentAttemptPaymentProviderConverter))] +public enum InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider +{ + Stripe, +} + +sealed class InvoiceIssueSummaryResponsePaymentAttemptPaymentProviderConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "stripe" => InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + _ => (InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe => "stripe", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(InvoiceIssueSummaryResponseStatusConverter))] +public enum InvoiceIssueSummaryResponseStatus +{ + Issued, + Paid, + Synced, + Void, + Draft, +} + +sealed class InvoiceIssueSummaryResponseStatusConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "issued" => InvoiceIssueSummaryResponseStatus.Issued, + "paid" => InvoiceIssueSummaryResponseStatus.Paid, + "synced" => InvoiceIssueSummaryResponseStatus.Synced, + "void" => InvoiceIssueSummaryResponseStatus.Void, + "draft" => InvoiceIssueSummaryResponseStatus.Draft, + _ => (InvoiceIssueSummaryResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponseStatus.Issued => "issued", + InvoiceIssueSummaryResponseStatus.Paid => "paid", + InvoiceIssueSummaryResponseStatus.Synced => "synced", + InvoiceIssueSummaryResponseStatus.Void => "void", + InvoiceIssueSummaryResponseStatus.Draft => "draft", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs new file mode 100644 index 000000000..9f769cd21 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// This endpoint is used to create a new license type. +/// +/// License types are used to group licenses and define billing behavior. Each +/// license type has a name and a grouping key that determines how metrics are aggregated +/// for billing purposes. +/// +/// 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 record class LicenseTypeCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("grouping_key"); + } + init { this._rawBodyData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("name"); + } + init { this._rawBodyData.Set("name", value); } + } + + public LicenseTypeCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeCreateParams(LicenseTypeCreateParams licenseTypeCreateParams) + : base(licenseTypeCreateParams) + { + this._rawBodyData = new(licenseTypeCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public LicenseTypeCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(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(LicenseTypeCreateParams? 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('/') + "/license_types") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeCreateResponse.cs b/src/Orb/Models/LicenseTypes/LicenseTypeCreateResponse.cs new file mode 100644 index 000000000..c600449ed --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeCreateResponse.cs @@ -0,0 +1,104 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class LicenseTypeCreateResponse : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public LicenseTypeCreateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeCreateResponse(LicenseTypeCreateResponse licenseTypeCreateResponse) + : base(licenseTypeCreateResponse) { } +#pragma warning restore CS8618 + + public LicenseTypeCreateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeCreateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeCreateResponseFromRaw : IFromRawJson +{ + /// + public LicenseTypeCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseTypeCreateResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs new file mode 100644 index 000000000..84d4b8b9e --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Exceptions; +using Orb.Services; + +namespace Orb.Models.LicenseTypes; + +/// +/// A single page from the paginated endpoint that queries. +/// +public sealed class LicenseTypeListPage( + ILicenseTypeServiceWithRawResponse service, + LicenseTypeListParams parameters, + LicenseTypeListPageResponse response +) : IPage +{ + /// + public IReadOnlyList Items + { + get { return response.Data; } + } + + /// + public bool HasNext() + { + try + { + return this.Items.Count > 0 && response.PaginationMetadata.NextCursor != null; + } + catch (OrbInvalidDataException) + { + // If accessing the response data to determine if there's a next page failed, then just + // assume there's no next page. + return false; + } + } + + /// + async Task> IPage.Next( + CancellationToken cancellationToken + ) => await this.Next(cancellationToken).ConfigureAwait(false); + + /// + public async Task Next(CancellationToken cancellationToken = default) + { + var nextCursor = + response.PaginationMetadata.NextCursor + ?? throw new InvalidOperationException("Cannot request next page"); + using var nextResponse = await service + .List(parameters with { Cursor = nextCursor }, cancellationToken) + .ConfigureAwait(false); + return await nextResponse.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public void Validate() + { + response.Validate(); + } + + public override string ToString() => + JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not LicenseTypeListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListPageResponse.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListPageResponse.cs new file mode 100644 index 000000000..fcdfbde5c --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListPageResponse.cs @@ -0,0 +1,88 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class LicenseTypeListPageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("data"); + } + init + { + this._rawData.Set>( + "data", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public LicenseTypeListPageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeListPageResponse(LicenseTypeListPageResponse licenseTypeListPageResponse) + : base(licenseTypeListPageResponse) { } +#pragma warning restore CS8618 + + public LicenseTypeListPageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeListPageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeListPageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeListPageResponseFromRaw : IFromRawJson +{ + /// + public LicenseTypeListPageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseTypeListPageResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs new file mode 100644 index 000000000..153b7afc1 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// This endpoint returns a list of all license types configured for the account, +/// ordered in ascending order by creation time. +/// +/// License types are used to group licenses and define billing behavior. Each +/// license type has a name and a grouping key that determines how metrics are aggregated +/// for billing purposes. +/// +/// 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 record class LicenseTypeListParams : ParamsBase +{ + /// + /// Cursor for pagination. This can be populated by the `next_cursor` value returned + /// from the initial request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + /// + /// The number of items to fetch. Defaults to 20. + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + public LicenseTypeListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeListParams(LicenseTypeListParams licenseTypeListParams) + : base(licenseTypeListParams) { } +#pragma warning restore CS8618 + + public LicenseTypeListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseTypeListParams? 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('/') + "/license_types") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListResponse.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListResponse.cs new file mode 100644 index 000000000..b3f5fa6bd --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListResponse.cs @@ -0,0 +1,102 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseTypeListResponse : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public LicenseTypeListResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeListResponse(LicenseTypeListResponse licenseTypeListResponse) + : base(licenseTypeListResponse) { } +#pragma warning restore CS8618 + + public LicenseTypeListResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeListResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeListResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeListResponseFromRaw : IFromRawJson +{ + /// + public LicenseTypeListResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseTypeListResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs new file mode 100644 index 000000000..b7f266c52 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// This endpoint returns a license type identified by its license_type_id. +/// +/// Use this endpoint to retrieve details about a specific license type, including +/// its name and grouping key. +/// +/// 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 record class LicenseTypeRetrieveParams : ParamsBase +{ + public string? LicenseTypeID { get; init; } + + public LicenseTypeRetrieveParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeRetrieveParams(LicenseTypeRetrieveParams licenseTypeRetrieveParams) + : base(licenseTypeRetrieveParams) + { + this.LicenseTypeID = licenseTypeRetrieveParams.LicenseTypeID; + } +#pragma warning restore CS8618 + + public LicenseTypeRetrieveParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeRetrieveParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeRetrieveParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["LicenseTypeID"] = this.LicenseTypeID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseTypeRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.LicenseTypeID?.Equals(other.LicenseTypeID) ?? other.LicenseTypeID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/license_types/{0}", this.LicenseTypeID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveResponse.cs b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveResponse.cs new file mode 100644 index 000000000..e270f62ef --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveResponse.cs @@ -0,0 +1,104 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class LicenseTypeRetrieveResponse : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public LicenseTypeRetrieveResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeRetrieveResponse(LicenseTypeRetrieveResponse licenseTypeRetrieveResponse) + : base(licenseTypeRetrieveResponse) { } +#pragma warning restore CS8618 + + public LicenseTypeRetrieveResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeRetrieveResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeRetrieveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeRetrieveResponseFromRaw : IFromRawJson +{ + /// + public LicenseTypeRetrieveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseTypeRetrieveResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs new file mode 100644 index 000000000..6a0c4d15e --- /dev/null +++ b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs @@ -0,0 +1,228 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses.ExternalLicenses; + +/// +/// Returns usage and remaining credits for a license identified by its external +/// license ID. +/// +/// Date range defaults to the current billing period 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 record class ExternalLicenseGetUsageParams : ParamsBase +{ + public string? ExternalLicenseID { get; init; } + + /// + /// The license type ID to filter licenses by. + /// + public required string LicenseTypeID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("license_type_id"); + } + init { this._rawQueryData.Set("license_type_id", value); } + } + + /// + /// The subscription ID to get license usage for. + /// + public required string SubscriptionID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("subscription_id"); + } + init { this._rawQueryData.Set("subscription_id", value); } + } + + /// + /// Pagination cursor from a previous request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + /// + /// End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + /// + public string? EndDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("end_date"); + } + init { this._rawQueryData.Set("end_date", value); } + } + + /// + /// How to group the results. Valid values: 'license', 'day'. Can be combined + /// (e.g., 'license,day'). + /// + public IReadOnlyList? GroupBy + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct>("group_by"); + } + init + { + this._rawQueryData.Set?>( + "group_by", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Maximum number of rows in the response data (default 20, max 100). + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + /// + /// Start date for the usage period (YYYY-MM-DD). Defaults to start of current + /// billing period. + /// + public string? StartDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("start_date"); + } + init { this._rawQueryData.Set("start_date", value); } + } + + public ExternalLicenseGetUsageParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExternalLicenseGetUsageParams( + ExternalLicenseGetUsageParams externalLicenseGetUsageParams + ) + : base(externalLicenseGetUsageParams) + { + this.ExternalLicenseID = externalLicenseGetUsageParams.ExternalLicenseID; + } +#pragma warning restore CS8618 + + public ExternalLicenseGetUsageParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExternalLicenseGetUsageParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static ExternalLicenseGetUsageParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalLicenseID"] = this.ExternalLicenseID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalLicenseGetUsageParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalLicenseID?.Equals(other.ExternalLicenseID) + ?? other.ExternalLicenseID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/licenses/external_licenses/{0}/usage", this.ExternalLicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponse.cs b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponse.cs new file mode 100644 index 000000000..fc83ac508 --- /dev/null +++ b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponse.cs @@ -0,0 +1,309 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.Licenses.ExternalLicenses; + +[JsonConverter( + typeof(JsonModelConverter< + ExternalLicenseGetUsageResponse, + ExternalLicenseGetUsageResponseFromRaw + >) +)] +public sealed record class ExternalLicenseGetUsageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("data"); + } + init + { + this._rawData.Set>("data", ImmutableArray.ToImmutableArray(value)); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public ExternalLicenseGetUsageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExternalLicenseGetUsageResponse( + ExternalLicenseGetUsageResponse externalLicenseGetUsageResponse + ) + : base(externalLicenseGetUsageResponse) { } +#pragma warning restore CS8618 + + public ExternalLicenseGetUsageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExternalLicenseGetUsageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ExternalLicenseGetUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExternalLicenseGetUsageResponseFromRaw : IFromRawJson +{ + /// + public ExternalLicenseGetUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ExternalLicenseGetUsageResponse.FromRawUnchecked(rawData); +} + +/// +/// The LicenseUsage resource represents usage and remaining credits for a license +/// over a date range. +/// +/// When grouped by 'day' only, license_id and external_license_id will be +/// null as the data is aggregated across all licenses. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Data : JsonModel +{ + /// + /// The total credits allocated to this license for the period. + /// + public required double AllocatedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("allocated_credits"); + } + init { this._rawData.Set("allocated_credits", value); } + } + + /// + /// The credits consumed by this license for the period. + /// + public required double ConsumedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("consumed_credits"); + } + init { this._rawData.Set("consumed_credits", value); } + } + + /// + /// The end date of the usage period. + /// + public required string EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + /// + /// The unique identifier for the license type. + /// + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// The pricing unit for the credits (e.g., 'credits'). + /// + public required string PricingUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_unit"); + } + init { this._rawData.Set("pricing_unit", value); } + } + + /// + /// The remaining credits available for this license (allocated - consumed). + /// + public required double RemainingCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("remaining_credits"); + } + init { this._rawData.Set("remaining_credits", value); } + } + + /// + /// The start date of the usage period. + /// + public required string StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + /// + /// The unique identifier for the subscription. + /// + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + /// Credits consumed while the license was active (eligible for individual allocation deduction). + /// + public double? AllocationEligibleCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("allocation_eligible_credits"); + } + init { this._rawData.Set("allocation_eligible_credits", value); } + } + + /// + /// The external identifier for the license. Null when grouped by day only. + /// + public string? ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + /// + /// The unique identifier for the license. Null when grouped by day only. + /// + public string? LicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_id"); + } + init { this._rawData.Set("license_id", value); } + } + + /// + /// Credits consumed while the license was inactive (draws from shared pool, not + /// individual allocation). + /// + public double? SharedPoolCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("shared_pool_credits"); + } + init { this._rawData.Set("shared_pool_credits", value); } + } + + /// + public override void Validate() + { + _ = this.AllocatedCredits; + _ = this.ConsumedCredits; + _ = this.EndDate; + _ = this.LicenseTypeID; + _ = this.PricingUnit; + _ = this.RemainingCredits; + _ = this.StartDate; + _ = this.SubscriptionID; + _ = this.AllocationEligibleCredits; + _ = this.ExternalLicenseID; + _ = this.LicenseID; + _ = this.SharedPoolCredits; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Data(Data data) + : base(data) { } +#pragma warning restore CS8618 + + public Data(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DataFromRaw : IFromRawJson +{ + /// + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Licenses/LicenseCreateParams.cs b/src/Orb/Models/Licenses/LicenseCreateParams.cs new file mode 100644 index 000000000..8b332eb3c --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseCreateParams.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint is used to create a new license for a user. +/// +/// If a start date is provided, the license will be activated at the **start** +/// of the specified date in the customer's timezone. Otherwise, the activation time +/// will default to the **start** of the current day in the customer's timezone. +/// +/// 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 record class LicenseCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The external identifier for the license. + /// + public required string ExternalLicenseID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("external_license_id"); + } + init { this._rawBodyData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("license_type_id"); + } + init { this._rawBodyData.Set("license_type_id", value); } + } + + public required string SubscriptionID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("subscription_id"); + } + init { this._rawBodyData.Set("subscription_id", value); } + } + + /// + /// The end date of the license. If not provided, the license will remain active + /// until deactivated. + /// + public string? EndDate + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("end_date"); + } + init { this._rawBodyData.Set("end_date", value); } + } + + /// + /// The start date of the license. If not provided, defaults to start of day + /// today in the customer's timezone. + /// + public string? StartDate + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("start_date"); + } + init { this._rawBodyData.Set("start_date", value); } + } + + public LicenseCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseCreateParams(LicenseCreateParams licenseCreateParams) + : base(licenseCreateParams) + { + this._rawBodyData = new(licenseCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public LicenseCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static LicenseCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(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(LicenseCreateParams? 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('/') + "/licenses") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/LicenseCreateResponse.cs b/src/Orb/Models/Licenses/LicenseCreateResponse.cs new file mode 100644 index 000000000..a7a3e5090 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseCreateResponse.cs @@ -0,0 +1,179 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseCreateResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "status" + ); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseCreateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseCreateResponse(LicenseCreateResponse licenseCreateResponse) + : base(licenseCreateResponse) { } +#pragma warning restore CS8618 + + public LicenseCreateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseCreateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseCreateResponseFromRaw : IFromRawJson +{ + /// + public LicenseCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseCreateResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseCreateResponseStatusConverter))] +public enum LicenseCreateResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseCreateResponseStatusConverter : JsonConverter +{ + public override LicenseCreateResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseCreateResponseStatus.Active, + "inactive" => LicenseCreateResponseStatus.Inactive, + _ => (LicenseCreateResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseCreateResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseCreateResponseStatus.Active => "active", + LicenseCreateResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseDeactivateParams.cs b/src/Orb/Models/Licenses/LicenseDeactivateParams.cs new file mode 100644 index 000000000..4369411ae --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseDeactivateParams.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint is used to deactivate an existing license. +/// +/// If an end date is provided, the license will be deactivated at the **start** +/// of the specified date in the customer's timezone. Otherwise, the deactivation +/// time will default to the **end** of the current day in the customer's timezone. +/// +/// 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 record class LicenseDeactivateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? LicenseID { get; init; } + + /// + /// The date to deactivate the license. If not provided, defaults to end of day + /// today in the customer's timezone. + /// + public string? EndDate + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("end_date"); + } + init { this._rawBodyData.Set("end_date", value); } + } + + public LicenseDeactivateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseDeactivateParams(LicenseDeactivateParams licenseDeactivateParams) + : base(licenseDeactivateParams) + { + this.LicenseID = licenseDeactivateParams.LicenseID; + + this._rawBodyData = new(licenseDeactivateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public LicenseDeactivateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseDeactivateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static LicenseDeactivateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["LicenseID"] = this.LicenseID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseDeactivateParams? other) + { + if (other == null) + { + return false; + } + return (this.LicenseID?.Equals(other.LicenseID) ?? other.LicenseID == 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( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/licenses/{0}/deactivate", this.LicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/LicenseDeactivateResponse.cs b/src/Orb/Models/Licenses/LicenseDeactivateResponse.cs new file mode 100644 index 000000000..2e6daef7d --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseDeactivateResponse.cs @@ -0,0 +1,182 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class LicenseDeactivateResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "status" + ); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseDeactivateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseDeactivateResponse(LicenseDeactivateResponse licenseDeactivateResponse) + : base(licenseDeactivateResponse) { } +#pragma warning restore CS8618 + + public LicenseDeactivateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseDeactivateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseDeactivateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseDeactivateResponseFromRaw : IFromRawJson +{ + /// + public LicenseDeactivateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseDeactivateResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseDeactivateResponseStatusConverter))] +public enum LicenseDeactivateResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseDeactivateResponseStatusConverter + : JsonConverter +{ + public override LicenseDeactivateResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseDeactivateResponseStatus.Active, + "inactive" => LicenseDeactivateResponseStatus.Inactive, + _ => (LicenseDeactivateResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseDeactivateResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseDeactivateResponseStatus.Active => "active", + LicenseDeactivateResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseListPage.cs b/src/Orb/Models/Licenses/LicenseListPage.cs new file mode 100644 index 000000000..43945bcd0 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListPage.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Exceptions; +using Orb.Services; + +namespace Orb.Models.Licenses; + +/// +/// A single page from the paginated endpoint that queries. +/// +public sealed class LicenseListPage( + ILicenseServiceWithRawResponse service, + LicenseListParams parameters, + LicenseListPageResponse response +) : IPage +{ + /// + public IReadOnlyList Items + { + get { return response.Data; } + } + + /// + public bool HasNext() + { + try + { + return this.Items.Count > 0 && response.PaginationMetadata.NextCursor != null; + } + catch (OrbInvalidDataException) + { + // If accessing the response data to determine if there's a next page failed, then just + // assume there's no next page. + return false; + } + } + + /// + async Task> IPage.Next( + CancellationToken cancellationToken + ) => await this.Next(cancellationToken).ConfigureAwait(false); + + /// + public async Task Next(CancellationToken cancellationToken = default) + { + var nextCursor = + response.PaginationMetadata.NextCursor + ?? throw new InvalidOperationException("Cannot request next page"); + using var nextResponse = await service + .List(parameters with { Cursor = nextCursor }, cancellationToken) + .ConfigureAwait(false); + return await nextResponse.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public void Validate() + { + response.Validate(); + } + + public override string ToString() => + JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + + public override bool Equals(object? obj) + { + if (obj is not LicenseListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; +} diff --git a/src/Orb/Models/Licenses/LicenseListPageResponse.cs b/src/Orb/Models/Licenses/LicenseListPageResponse.cs new file mode 100644 index 000000000..4079dc8a6 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListPageResponse.cs @@ -0,0 +1,86 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.Licenses; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseListPageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("data"); + } + init + { + this._rawData.Set>( + "data", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public LicenseListPageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseListPageResponse(LicenseListPageResponse licenseListPageResponse) + : base(licenseListPageResponse) { } +#pragma warning restore CS8618 + + public LicenseListPageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseListPageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseListPageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseListPageResponseFromRaw : IFromRawJson +{ + /// + public LicenseListPageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseListPageResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Licenses/LicenseListParams.cs b/src/Orb/Models/Licenses/LicenseListParams.cs new file mode 100644 index 000000000..867670aff --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListParams.cs @@ -0,0 +1,219 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint returns a list of all licenses for 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 record class LicenseListParams : ParamsBase +{ + public required string SubscriptionID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("subscription_id"); + } + init { this._rawQueryData.Set("subscription_id", value); } + } + + /// + /// Cursor for pagination. This can be populated by the `next_cursor` value returned + /// from the initial request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + public string? ExternalLicenseID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("external_license_id"); + } + init { this._rawQueryData.Set("external_license_id", value); } + } + + public string? LicenseTypeID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("license_type_id"); + } + init { this._rawQueryData.Set("license_type_id", value); } + } + + /// + /// The number of items to fetch. Defaults to 20. + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + public ApiEnum? Status + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass>("status"); + } + init { this._rawQueryData.Set("status", value); } + } + + public LicenseListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseListParams(LicenseListParams licenseListParams) + : base(licenseListParams) { } +#pragma warning restore CS8618 + + public LicenseListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static LicenseListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseListParams? 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('/') + "/licenses") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +[JsonConverter(typeof(StatusConverter))] +public enum Status +{ + Active, + Inactive, +} + +sealed class StatusConverter : JsonConverter +{ + public override Status Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => Status.Active, + "inactive" => Status.Inactive, + _ => (Status)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Status.Active => "active", + Status.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseListResponse.cs b/src/Orb/Models/Licenses/LicenseListResponse.cs new file mode 100644 index 000000000..6c6f6061f --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListResponse.cs @@ -0,0 +1,178 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseListResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "status" + ); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseListResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseListResponse(LicenseListResponse licenseListResponse) + : base(licenseListResponse) { } +#pragma warning restore CS8618 + + public LicenseListResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseListResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseListResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseListResponseFromRaw : IFromRawJson +{ + /// + public LicenseListResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseListResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseListResponseStatusConverter))] +public enum LicenseListResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseListResponseStatusConverter : JsonConverter +{ + public override LicenseListResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseListResponseStatus.Active, + "inactive" => LicenseListResponseStatus.Inactive, + _ => (LicenseListResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseListResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseListResponseStatus.Active => "active", + LicenseListResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs new file mode 100644 index 000000000..a833a9221 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint is used to fetch a license given an external license 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 record class LicenseRetrieveByExternalIDParams : ParamsBase +{ + public string? ExternalLicenseID { get; init; } + + /// + /// The ID of the license type to fetch the license for. + /// + public required string LicenseTypeID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("license_type_id"); + } + init { this._rawQueryData.Set("license_type_id", value); } + } + + /// + /// The ID of the subscription to fetch the license for. + /// + public required string SubscriptionID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("subscription_id"); + } + init { this._rawQueryData.Set("subscription_id", value); } + } + + public LicenseRetrieveByExternalIDParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseRetrieveByExternalIDParams( + LicenseRetrieveByExternalIDParams licenseRetrieveByExternalIDParams + ) + : base(licenseRetrieveByExternalIDParams) + { + this.ExternalLicenseID = licenseRetrieveByExternalIDParams.ExternalLicenseID; + } +#pragma warning restore CS8618 + + public LicenseRetrieveByExternalIDParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseRetrieveByExternalIDParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveByExternalIDParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalLicenseID"] = this.ExternalLicenseID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseRetrieveByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalLicenseID?.Equals(other.ExternalLicenseID) + ?? other.ExternalLicenseID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/licenses/external_license_id/{0}", this.ExternalLicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDResponse.cs b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDResponse.cs new file mode 100644 index 000000000..5c47163e5 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDResponse.cs @@ -0,0 +1,187 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter( + typeof(JsonModelConverter< + LicenseRetrieveByExternalIDResponse, + LicenseRetrieveByExternalIDResponseFromRaw + >) +)] +public sealed record class LicenseRetrieveByExternalIDResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("status"); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseRetrieveByExternalIDResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseRetrieveByExternalIDResponse( + LicenseRetrieveByExternalIDResponse licenseRetrieveByExternalIDResponse + ) + : base(licenseRetrieveByExternalIDResponse) { } +#pragma warning restore CS8618 + + public LicenseRetrieveByExternalIDResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseRetrieveByExternalIDResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveByExternalIDResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseRetrieveByExternalIDResponseFromRaw : IFromRawJson +{ + /// + public LicenseRetrieveByExternalIDResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseRetrieveByExternalIDResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseRetrieveByExternalIDResponseStatusConverter))] +public enum LicenseRetrieveByExternalIDResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseRetrieveByExternalIDResponseStatusConverter + : JsonConverter +{ + public override LicenseRetrieveByExternalIDResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseRetrieveByExternalIDResponseStatus.Active, + "inactive" => LicenseRetrieveByExternalIDResponseStatus.Inactive, + _ => (LicenseRetrieveByExternalIDResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseRetrieveByExternalIDResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseRetrieveByExternalIDResponseStatus.Active => "active", + LicenseRetrieveByExternalIDResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseRetrieveParams.cs b/src/Orb/Models/Licenses/LicenseRetrieveParams.cs new file mode 100644 index 000000000..5e74714f6 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveParams.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint is used to fetch a license 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 record class LicenseRetrieveParams : ParamsBase +{ + public string? LicenseID { get; init; } + + public LicenseRetrieveParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseRetrieveParams(LicenseRetrieveParams licenseRetrieveParams) + : base(licenseRetrieveParams) + { + this.LicenseID = licenseRetrieveParams.LicenseID; + } +#pragma warning restore CS8618 + + public LicenseRetrieveParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseRetrieveParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["LicenseID"] = this.LicenseID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.LicenseID?.Equals(other.LicenseID) ?? other.LicenseID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + string.Format("/licenses/{0}", this.LicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/LicenseRetrieveResponse.cs b/src/Orb/Models/Licenses/LicenseRetrieveResponse.cs new file mode 100644 index 000000000..cb35e127d --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveResponse.cs @@ -0,0 +1,179 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseRetrieveResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "status" + ); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseRetrieveResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseRetrieveResponse(LicenseRetrieveResponse licenseRetrieveResponse) + : base(licenseRetrieveResponse) { } +#pragma warning restore CS8618 + + public LicenseRetrieveResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseRetrieveResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseRetrieveResponseFromRaw : IFromRawJson +{ + /// + public LicenseRetrieveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseRetrieveResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseRetrieveResponseStatusConverter))] +public enum LicenseRetrieveResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseRetrieveResponseStatusConverter : JsonConverter +{ + public override LicenseRetrieveResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseRetrieveResponseStatus.Active, + "inactive" => LicenseRetrieveResponseStatus.Inactive, + _ => (LicenseRetrieveResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseRetrieveResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseRetrieveResponseStatus.Active => "active", + LicenseRetrieveResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs new file mode 100644 index 000000000..792d3000e --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses.Usage; + +/// +/// Returns usage and remaining credits for all licenses of a given type on a subscription. +/// +/// Date range defaults to the current billing period 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 record class UsageGetAllUsageParams : ParamsBase +{ + /// + /// The license type ID to filter licenses by. + /// + public required string LicenseTypeID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("license_type_id"); + } + init { this._rawQueryData.Set("license_type_id", value); } + } + + /// + /// The subscription ID to get license usage for. + /// + public required string SubscriptionID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("subscription_id"); + } + init { this._rawQueryData.Set("subscription_id", value); } + } + + /// + /// Pagination cursor from a previous request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + /// + /// End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + /// + public string? EndDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("end_date"); + } + init { this._rawQueryData.Set("end_date", value); } + } + + /// + /// How to group the results. Valid values: 'license', 'day'. Can be combined + /// (e.g., 'license,day'). + /// + public IReadOnlyList? GroupBy + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct>("group_by"); + } + init + { + this._rawQueryData.Set?>( + "group_by", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Maximum number of rows in the response data (default 20, max 100). + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + /// + /// Start date for the usage period (YYYY-MM-DD). Defaults to start of current + /// billing period. + /// + public string? StartDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("start_date"); + } + init { this._rawQueryData.Set("start_date", value); } + } + + public UsageGetAllUsageParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetAllUsageParams(UsageGetAllUsageParams usageGetAllUsageParams) + : base(usageGetAllUsageParams) { } +#pragma warning restore CS8618 + + public UsageGetAllUsageParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetAllUsageParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetAllUsageParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UsageGetAllUsageParams? 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('/') + "/licenses/usage") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/Usage/UsageGetAllUsageResponse.cs b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageResponse.cs new file mode 100644 index 000000000..d2d50c3d8 --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageResponse.cs @@ -0,0 +1,304 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.Licenses.Usage; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UsageGetAllUsageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("data"); + } + init + { + this._rawData.Set>("data", ImmutableArray.ToImmutableArray(value)); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public UsageGetAllUsageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetAllUsageResponse(UsageGetAllUsageResponse usageGetAllUsageResponse) + : base(usageGetAllUsageResponse) { } +#pragma warning restore CS8618 + + public UsageGetAllUsageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetAllUsageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetAllUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageGetAllUsageResponseFromRaw : IFromRawJson +{ + /// + public UsageGetAllUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageGetAllUsageResponse.FromRawUnchecked(rawData); +} + +/// +/// The LicenseUsage resource represents usage and remaining credits for a license +/// over a date range. +/// +/// When grouped by 'day' only, license_id and external_license_id will be +/// null as the data is aggregated across all licenses. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Data : JsonModel +{ + /// + /// The total credits allocated to this license for the period. + /// + public required double AllocatedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("allocated_credits"); + } + init { this._rawData.Set("allocated_credits", value); } + } + + /// + /// The credits consumed by this license for the period. + /// + public required double ConsumedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("consumed_credits"); + } + init { this._rawData.Set("consumed_credits", value); } + } + + /// + /// The end date of the usage period. + /// + public required string EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + /// + /// The unique identifier for the license type. + /// + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// The pricing unit for the credits (e.g., 'credits'). + /// + public required string PricingUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_unit"); + } + init { this._rawData.Set("pricing_unit", value); } + } + + /// + /// The remaining credits available for this license (allocated - consumed). + /// + public required double RemainingCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("remaining_credits"); + } + init { this._rawData.Set("remaining_credits", value); } + } + + /// + /// The start date of the usage period. + /// + public required string StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + /// + /// The unique identifier for the subscription. + /// + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + /// Credits consumed while the license was active (eligible for individual allocation deduction). + /// + public double? AllocationEligibleCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("allocation_eligible_credits"); + } + init { this._rawData.Set("allocation_eligible_credits", value); } + } + + /// + /// The external identifier for the license. Null when grouped by day only. + /// + public string? ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + /// + /// The unique identifier for the license. Null when grouped by day only. + /// + public string? LicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_id"); + } + init { this._rawData.Set("license_id", value); } + } + + /// + /// Credits consumed while the license was inactive (draws from shared pool, not + /// individual allocation). + /// + public double? SharedPoolCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("shared_pool_credits"); + } + init { this._rawData.Set("shared_pool_credits", value); } + } + + /// + public override void Validate() + { + _ = this.AllocatedCredits; + _ = this.ConsumedCredits; + _ = this.EndDate; + _ = this.LicenseTypeID; + _ = this.PricingUnit; + _ = this.RemainingCredits; + _ = this.StartDate; + _ = this.SubscriptionID; + _ = this.AllocationEligibleCredits; + _ = this.ExternalLicenseID; + _ = this.LicenseID; + _ = this.SharedPoolCredits; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Data(Data data) + : base(data) { } +#pragma warning restore CS8618 + + public Data(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DataFromRaw : IFromRawJson +{ + /// + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs b/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs new file mode 100644 index 000000000..d0d7f0dde --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses.Usage; + +/// +/// Returns usage and remaining credits for a specific license over a date range. +/// +/// Date range defaults to the current billing period 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 record class UsageGetUsageParams : ParamsBase +{ + public string? LicenseID { get; init; } + + /// + /// Pagination cursor from a previous request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + /// + /// End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + /// + public string? EndDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("end_date"); + } + init { this._rawQueryData.Set("end_date", value); } + } + + /// + /// How to group the results. Valid values: 'license', 'day'. Can be combined + /// (e.g., 'license,day'). + /// + public IReadOnlyList? GroupBy + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct>("group_by"); + } + init + { + this._rawQueryData.Set?>( + "group_by", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Maximum number of rows in the response data (default 20, max 100). + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + /// + /// Start date for the usage period (YYYY-MM-DD). Defaults to start of current + /// billing period. + /// + public string? StartDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("start_date"); + } + init { this._rawQueryData.Set("start_date", value); } + } + + public UsageGetUsageParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetUsageParams(UsageGetUsageParams usageGetUsageParams) + : base(usageGetUsageParams) + { + this.LicenseID = usageGetUsageParams.LicenseID; + } +#pragma warning restore CS8618 + + public UsageGetUsageParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetUsageParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetUsageParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["LicenseID"] = this.LicenseID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UsageGetUsageParams? other) + { + if (other == null) + { + return false; + } + return (this.LicenseID?.Equals(other.LicenseID) ?? other.LicenseID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/licenses/{0}/usage", this.LicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/Usage/UsageGetUsageResponse.cs b/src/Orb/Models/Licenses/Usage/UsageGetUsageResponse.cs new file mode 100644 index 000000000..47a383f1c --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetUsageResponse.cs @@ -0,0 +1,312 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.Licenses.Usage; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UsageGetUsageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "data" + ); + } + init + { + this._rawData.Set>( + "data", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public UsageGetUsageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetUsageResponse(UsageGetUsageResponse usageGetUsageResponse) + : base(usageGetUsageResponse) { } +#pragma warning restore CS8618 + + public UsageGetUsageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetUsageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageGetUsageResponseFromRaw : IFromRawJson +{ + /// + public UsageGetUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageGetUsageResponse.FromRawUnchecked(rawData); +} + +/// +/// The LicenseUsage resource represents usage and remaining credits for a license +/// over a date range. +/// +/// When grouped by 'day' only, license_id and external_license_id will be +/// null as the data is aggregated across all licenses. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UsageGetUsageResponseData : JsonModel +{ + /// + /// The total credits allocated to this license for the period. + /// + public required double AllocatedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("allocated_credits"); + } + init { this._rawData.Set("allocated_credits", value); } + } + + /// + /// The credits consumed by this license for the period. + /// + public required double ConsumedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("consumed_credits"); + } + init { this._rawData.Set("consumed_credits", value); } + } + + /// + /// The end date of the usage period. + /// + public required string EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + /// + /// The unique identifier for the license type. + /// + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// The pricing unit for the credits (e.g., 'credits'). + /// + public required string PricingUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_unit"); + } + init { this._rawData.Set("pricing_unit", value); } + } + + /// + /// The remaining credits available for this license (allocated - consumed). + /// + public required double RemainingCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("remaining_credits"); + } + init { this._rawData.Set("remaining_credits", value); } + } + + /// + /// The start date of the usage period. + /// + public required string StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + /// + /// The unique identifier for the subscription. + /// + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + /// Credits consumed while the license was active (eligible for individual allocation deduction). + /// + public double? AllocationEligibleCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("allocation_eligible_credits"); + } + init { this._rawData.Set("allocation_eligible_credits", value); } + } + + /// + /// The external identifier for the license. Null when grouped by day only. + /// + public string? ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + /// + /// The unique identifier for the license. Null when grouped by day only. + /// + public string? LicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_id"); + } + init { this._rawData.Set("license_id", value); } + } + + /// + /// Credits consumed while the license was inactive (draws from shared pool, not + /// individual allocation). + /// + public double? SharedPoolCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("shared_pool_credits"); + } + init { this._rawData.Set("shared_pool_credits", value); } + } + + /// + public override void Validate() + { + _ = this.AllocatedCredits; + _ = this.ConsumedCredits; + _ = this.EndDate; + _ = this.LicenseTypeID; + _ = this.PricingUnit; + _ = this.RemainingCredits; + _ = this.StartDate; + _ = this.SubscriptionID; + _ = this.AllocationEligibleCredits; + _ = this.ExternalLicenseID; + _ = this.LicenseID; + _ = this.SharedPoolCredits; + } + + public UsageGetUsageResponseData() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetUsageResponseData(UsageGetUsageResponseData usageGetUsageResponseData) + : base(usageGetUsageResponseData) { } +#pragma warning restore CS8618 + + public UsageGetUsageResponseData(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetUsageResponseData(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetUsageResponseData FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageGetUsageResponseDataFromRaw : IFromRawJson +{ + /// + public UsageGetUsageResponseData FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageGetUsageResponseData.FromRawUnchecked(rawData); +} diff --git a/src/Orb/OrbClient.cs b/src/Orb/OrbClient.cs index f3af3071e..ebdebeb8c 100644 --- a/src/Orb/OrbClient.cs +++ b/src/Orb/OrbClient.cs @@ -181,6 +181,18 @@ public ICreditBlockService CreditBlocks get { return _creditBlocks.Value; } } + readonly Lazy _licenseTypes; + public ILicenseTypeService LicenseTypes + { + get { return _licenseTypes.Value; } + } + + readonly Lazy _licenses; + public ILicenseService Licenses + { + get { return _licenses.Value; } + } + public void Dispose() => this.HttpClient.Dispose(); public OrbClient() @@ -205,6 +217,8 @@ public OrbClient() _dimensionalPriceGroups = new(() => new DimensionalPriceGroupService(this)); _subscriptionChanges = new(() => new SubscriptionChangeService(this)); _creditBlocks = new(() => new CreditBlockService(this)); + _licenseTypes = new(() => new LicenseTypeService(this)); + _licenses = new(() => new LicenseService(this)); } public OrbClient(ClientOptions options) @@ -387,6 +401,18 @@ public ICreditBlockServiceWithRawResponse CreditBlocks get { return _creditBlocks.Value; } } + readonly Lazy _licenseTypes; + public ILicenseTypeServiceWithRawResponse LicenseTypes + { + get { return _licenseTypes.Value; } + } + + readonly Lazy _licenses; + public ILicenseServiceWithRawResponse Licenses + { + get { return _licenses.Value; } + } + /// public async Task Execute( HttpRequest request, @@ -609,6 +635,8 @@ public OrbClientWithRawResponse() _dimensionalPriceGroups = new(() => new DimensionalPriceGroupServiceWithRawResponse(this)); _subscriptionChanges = new(() => new SubscriptionChangeServiceWithRawResponse(this)); _creditBlocks = new(() => new CreditBlockServiceWithRawResponse(this)); + _licenseTypes = new(() => new LicenseTypeServiceWithRawResponse(this)); + _licenses = new(() => new LicenseServiceWithRawResponse(this)); } public OrbClientWithRawResponse(ClientOptions options) diff --git a/src/Orb/Services/CreditBlockService.cs b/src/Orb/Services/CreditBlockService.cs index db191692f..0bac71674 100644 --- a/src/Orb/Services/CreditBlockService.cs +++ b/src/Orb/Services/CreditBlockService.cs @@ -79,6 +79,30 @@ public async Task Delete( await this.Delete(parameters with { BlockID = blockID }, cancellationToken) .ConfigureAwait(false); } + + /// + public async Task ListInvoices( + CreditBlockListInvoicesParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.ListInvoices(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task ListInvoices( + string blockID, + CreditBlockListInvoicesParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.ListInvoices(parameters with { BlockID = blockID }, cancellationToken); + } } /// @@ -174,4 +198,49 @@ public Task Delete( return this.Delete(parameters with { BlockID = blockID }, cancellationToken); } + + /// + public async Task> ListInvoices( + CreditBlockListInvoicesParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.BlockID == null) + { + throw new OrbInvalidDataException("'parameters.BlockID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public Task> ListInvoices( + string blockID, + CreditBlockListInvoicesParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.ListInvoices(parameters with { BlockID = blockID }, cancellationToken); + } } diff --git a/src/Orb/Services/ICreditBlockService.cs b/src/Orb/Services/ICreditBlockService.cs index c2d358645..4c952dc61 100644 --- a/src/Orb/Services/ICreditBlockService.cs +++ b/src/Orb/Services/ICreditBlockService.cs @@ -62,6 +62,34 @@ Task Delete( CreditBlockDeleteParams? parameters = null, CancellationToken cancellationToken = default ); + + /// + /// This endpoint returns the credit block and its associated purchasing invoices. + /// + /// If a credit block was purchased (as opposed to being manually added + /// or allocated from a subscription), this endpoint returns the invoices that + /// were created to charge the customer for the credit block. For credit blocks + /// with payment schedules spanning multiple periods (e.g., monthly payments over + /// 12 months), multiple invoices will be returned. + /// + /// If the credit block was not purchased (e.g., manual increment, allocation), + /// an empty invoices list is returned. + /// + /// **Note: This endpoint is currently experimental and its interface may + /// change in future releases. Please contact support before building production + /// integrations against this endpoint.** + /// + Task ListInvoices( + CreditBlockListInvoicesParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task ListInvoices( + string blockID, + CreditBlockListInvoicesParams? parameters = null, + CancellationToken cancellationToken = default + ); } /// @@ -108,4 +136,20 @@ Task Delete( CreditBlockDeleteParams? parameters = null, CancellationToken cancellationToken = default ); + + /// + /// Returns a raw HTTP response for `get /credit_blocks/{block_id}/invoices`, but is otherwise the + /// same as . + /// + Task> ListInvoices( + CreditBlockListInvoicesParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> ListInvoices( + string blockID, + CreditBlockListInvoicesParams? parameters = null, + CancellationToken cancellationToken = default + ); } diff --git a/src/Orb/Services/IInvoiceService.cs b/src/Orb/Services/IInvoiceService.cs index 36d477592..ee5112f24 100644 --- a/src/Orb/Services/IInvoiceService.cs +++ b/src/Orb/Services/IInvoiceService.cs @@ -138,6 +138,29 @@ Task Issue( CancellationToken cancellationToken = default ); + /// + /// This endpoint allows an eligible invoice to be issued manually. This is only + /// possible with invoices where status is `draft`, `will_auto_issue` is false, + /// and an `eligible_to_issue_at` 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). + /// + /// This is a lighter-weight alternative to the issue invoice endpoint, + /// returning an invoice summary without any line item details. + /// + Task IssueSummary( + InvoiceIssueSummaryParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task IssueSummary( + string invoiceID, + InvoiceIssueSummaryParams? parameters = null, + CancellationToken cancellationToken = default + ); + /// /// This is a lighter-weight endpoint that returns a list of all [`Invoice`](/core-concepts#invoice) /// summaries for an account in a list format. @@ -316,6 +339,22 @@ Task> Issue( CancellationToken cancellationToken = default ); + /// + /// Returns a raw HTTP response for `post /invoices/summary/{invoice_id}/issue`, but is otherwise the + /// same as . + /// + Task> IssueSummary( + InvoiceIssueSummaryParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> IssueSummary( + string invoiceID, + InvoiceIssueSummaryParams? parameters = null, + CancellationToken cancellationToken = default + ); + /// /// Returns a raw HTTP response for `get /invoices/summary`, but is otherwise the /// same as . diff --git a/src/Orb/Services/ILicenseService.cs b/src/Orb/Services/ILicenseService.cs new file mode 100644 index 000000000..ef909883b --- /dev/null +++ b/src/Orb/Services/ILicenseService.cs @@ -0,0 +1,186 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Models.Licenses; +using Orb.Services.Licenses; + +namespace Orb.Services; + +/// +/// 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 interface ILicenseService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + ILicenseServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ILicenseService WithOptions(Func modifier); + + IExternalLicenseService ExternalLicenses { get; } + + IUsageService Usage { get; } + + /// + /// This endpoint is used to create a new license for a user. + /// + /// If a start date is provided, the license will be activated at the **start** + /// of the specified date in the customer's timezone. Otherwise, the activation + /// time will default to the **start** of the current day in the customer's timezone. + /// + Task Create( + LicenseCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This endpoint is used to fetch a license given an identifier. + /// + Task Retrieve( + LicenseRetrieveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Retrieve( + string licenseID, + LicenseRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This endpoint returns a list of all licenses for a subscription. + /// + Task List( + LicenseListParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This endpoint is used to deactivate an existing license. + /// + /// If an end date is provided, the license will be deactivated at the **start** + /// of the specified date in the customer's timezone. Otherwise, the deactivation + /// time will default to the **end** of the current day in the customer's timezone. + /// + Task Deactivate( + LicenseDeactivateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Deactivate( + string licenseID, + LicenseDeactivateParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This endpoint is used to fetch a license given an external license identifier. + /// + Task RetrieveByExternalID( + LicenseRetrieveByExternalIDParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task RetrieveByExternalID( + string externalLicenseID, + LicenseRetrieveByExternalIDParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface ILicenseServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ILicenseServiceWithRawResponse WithOptions(Func modifier); + + IExternalLicenseServiceWithRawResponse ExternalLicenses { get; } + + IUsageServiceWithRawResponse Usage { get; } + + /// + /// Returns a raw HTTP response for `post /licenses`, but is otherwise the + /// same as . + /// + Task> Create( + LicenseCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /licenses/{license_id}`, but is otherwise the + /// same as . + /// + Task> Retrieve( + LicenseRetrieveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Retrieve( + string licenseID, + LicenseRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /licenses`, but is otherwise the + /// same as . + /// + Task> List( + LicenseListParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `post /licenses/{license_id}/deactivate`, but is otherwise the + /// same as . + /// + Task> Deactivate( + LicenseDeactivateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Deactivate( + string licenseID, + LicenseDeactivateParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /licenses/external_license_id/{external_license_id}`, but is otherwise the + /// same as . + /// + Task> RetrieveByExternalID( + LicenseRetrieveByExternalIDParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> RetrieveByExternalID( + string externalLicenseID, + LicenseRetrieveByExternalIDParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/Orb/Services/ILicenseTypeService.cs b/src/Orb/Services/ILicenseTypeService.cs new file mode 100644 index 000000000..393e2e02b --- /dev/null +++ b/src/Orb/Services/ILicenseTypeService.cs @@ -0,0 +1,119 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Models.LicenseTypes; + +namespace Orb.Services; + +/// +/// 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 interface ILicenseTypeService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + ILicenseTypeServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ILicenseTypeService WithOptions(Func modifier); + + /// + /// This endpoint is used to create a new license type. + /// + /// License types are used to group licenses and define billing behavior. + /// Each license type has a name and a grouping key that determines how metrics + /// are aggregated for billing purposes. + /// + Task Create( + LicenseTypeCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// This endpoint returns a license type identified by its license_type_id. + /// + /// Use this endpoint to retrieve details about a specific license type, + /// including its name and grouping key. + /// + Task Retrieve( + LicenseTypeRetrieveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task Retrieve( + string licenseTypeID, + LicenseTypeRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// This endpoint returns a list of all license types configured for the account, + /// ordered in ascending order by creation time. + /// + /// License types are used to group licenses and define billing behavior. + /// Each license type has a name and a grouping key that determines how metrics + /// are aggregated for billing purposes. + /// + Task List( + LicenseTypeListParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface ILicenseTypeServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + ILicenseTypeServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `post /license_types`, but is otherwise the + /// same as . + /// + Task> Create( + LicenseTypeCreateParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /license_types/{license_type_id}`, but is otherwise the + /// same as . + /// + Task> Retrieve( + LicenseTypeRetrieveParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> Retrieve( + string licenseTypeID, + LicenseTypeRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /license_types`, but is otherwise the + /// same as . + /// + Task> List( + LicenseTypeListParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/Orb/Services/InvoiceService.cs b/src/Orb/Services/InvoiceService.cs index 60d3b6c40..d53683dfc 100644 --- a/src/Orb/Services/InvoiceService.cs +++ b/src/Orb/Services/InvoiceService.cs @@ -163,6 +163,30 @@ public Task Issue( return this.Issue(parameters with { InvoiceID = invoiceID }, cancellationToken); } + /// + public async Task IssueSummary( + InvoiceIssueSummaryParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.IssueSummary(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task IssueSummary( + string invoiceID, + InvoiceIssueSummaryParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.IssueSummary(parameters with { InvoiceID = invoiceID }, cancellationToken); + } + /// public async Task ListSummary( InvoiceListSummaryParams? parameters = null, @@ -504,6 +528,51 @@ public Task> Issue( return this.Issue(parameters with { InvoiceID = invoiceID }, cancellationToken); } + /// + public async Task> IssueSummary( + InvoiceIssueSummaryParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.InvoiceID == null) + { + throw new OrbInvalidDataException("'parameters.InvoiceID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public Task> IssueSummary( + string invoiceID, + InvoiceIssueSummaryParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.IssueSummary(parameters with { InvoiceID = invoiceID }, cancellationToken); + } + /// public async Task> ListSummary( InvoiceListSummaryParams? parameters = null, diff --git a/src/Orb/Services/LicenseService.cs b/src/Orb/Services/LicenseService.cs new file mode 100644 index 000000000..34d21c39b --- /dev/null +++ b/src/Orb/Services/LicenseService.cs @@ -0,0 +1,378 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses; +using Orb.Services.Licenses; + +namespace Orb.Services; + +/// +public sealed class LicenseService : ILicenseService +{ + readonly Lazy _withRawResponse; + + /// + public ILicenseServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IOrbClient _client; + + /// + public ILicenseService WithOptions(Func modifier) + { + return new LicenseService(this._client.WithOptions(modifier)); + } + + public LicenseService(IOrbClient client) + { + _client = client; + + _withRawResponse = new(() => new LicenseServiceWithRawResponse(client.WithRawResponse)); + _externalLicenses = new(() => new ExternalLicenseService(client)); + _usage = new(() => new UsageService(client)); + } + + readonly Lazy _externalLicenses; + public IExternalLicenseService ExternalLicenses + { + get { return _externalLicenses.Value; } + } + + readonly Lazy _usage; + public IUsageService Usage + { + get { return _usage.Value; } + } + + /// + public async Task Create( + LicenseCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Create(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Retrieve( + LicenseRetrieveParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Retrieve(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Retrieve( + string licenseID, + LicenseRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Retrieve(parameters with { LicenseID = licenseID }, cancellationToken); + } + + /// + public async Task List( + LicenseListParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.List(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Deactivate( + LicenseDeactivateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Deactivate(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Deactivate( + string licenseID, + LicenseDeactivateParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Deactivate(parameters with { LicenseID = licenseID }, cancellationToken); + } + + /// + public async Task RetrieveByExternalID( + LicenseRetrieveByExternalIDParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.RetrieveByExternalID(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task RetrieveByExternalID( + string externalLicenseID, + LicenseRetrieveByExternalIDParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.RetrieveByExternalID( + parameters with + { + ExternalLicenseID = externalLicenseID, + }, + cancellationToken + ); + } +} + +/// +public sealed class LicenseServiceWithRawResponse : ILicenseServiceWithRawResponse +{ + readonly IOrbClientWithRawResponse _client; + + /// + public ILicenseServiceWithRawResponse WithOptions(Func modifier) + { + return new LicenseServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public LicenseServiceWithRawResponse(IOrbClientWithRawResponse client) + { + _client = client; + + _externalLicenses = new(() => new ExternalLicenseServiceWithRawResponse(client)); + _usage = new(() => new UsageServiceWithRawResponse(client)); + } + + readonly Lazy _externalLicenses; + public IExternalLicenseServiceWithRawResponse ExternalLicenses + { + get { return _externalLicenses.Value; } + } + + readonly Lazy _usage; + public IUsageServiceWithRawResponse Usage + { + get { return _usage.Value; } + } + + /// + public async Task> Create( + LicenseCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var license = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + license.Validate(); + } + return license; + } + ); + } + + /// + public async Task> Retrieve( + LicenseRetrieveParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.LicenseID == null) + { + throw new OrbInvalidDataException("'parameters.LicenseID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var license = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + license.Validate(); + } + return license; + } + ); + } + + /// + public Task> Retrieve( + string licenseID, + LicenseRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Retrieve(parameters with { LicenseID = licenseID }, cancellationToken); + } + + /// + public async Task> List( + LicenseListParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var page = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + page.Validate(); + } + return new LicenseListPage(this, parameters, page); + } + ); + } + + /// + public async Task> Deactivate( + LicenseDeactivateParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.LicenseID == null) + { + throw new OrbInvalidDataException("'parameters.LicenseID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public Task> Deactivate( + string licenseID, + LicenseDeactivateParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Deactivate(parameters with { LicenseID = licenseID }, cancellationToken); + } + + /// + public async Task> RetrieveByExternalID( + LicenseRetrieveByExternalIDParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ExternalLicenseID == null) + { + throw new OrbInvalidDataException("'parameters.ExternalLicenseID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public Task> RetrieveByExternalID( + string externalLicenseID, + LicenseRetrieveByExternalIDParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.RetrieveByExternalID( + parameters with + { + ExternalLicenseID = externalLicenseID, + }, + cancellationToken + ); + } +} diff --git a/src/Orb/Services/LicenseTypeService.cs b/src/Orb/Services/LicenseTypeService.cs new file mode 100644 index 000000000..ed392dd89 --- /dev/null +++ b/src/Orb/Services/LicenseTypeService.cs @@ -0,0 +1,206 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.LicenseTypes; + +namespace Orb.Services; + +/// +public sealed class LicenseTypeService : ILicenseTypeService +{ + readonly Lazy _withRawResponse; + + /// + public ILicenseTypeServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IOrbClient _client; + + /// + public ILicenseTypeService WithOptions(Func modifier) + { + return new LicenseTypeService(this._client.WithOptions(modifier)); + } + + public LicenseTypeService(IOrbClient client) + { + _client = client; + + _withRawResponse = new(() => new LicenseTypeServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task Create( + LicenseTypeCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Create(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task Retrieve( + LicenseTypeRetrieveParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Retrieve(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task Retrieve( + string licenseTypeID, + LicenseTypeRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Retrieve(parameters with { LicenseTypeID = licenseTypeID }, cancellationToken); + } + + /// + public async Task List( + LicenseTypeListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.List(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class LicenseTypeServiceWithRawResponse : ILicenseTypeServiceWithRawResponse +{ + readonly IOrbClientWithRawResponse _client; + + /// + public ILicenseTypeServiceWithRawResponse WithOptions( + Func modifier + ) + { + return new LicenseTypeServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public LicenseTypeServiceWithRawResponse(IOrbClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Create( + LicenseTypeCreateParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Post, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var licenseType = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + licenseType.Validate(); + } + return licenseType; + } + ); + } + + /// + public async Task> Retrieve( + LicenseTypeRetrieveParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.LicenseTypeID == null) + { + throw new OrbInvalidDataException("'parameters.LicenseTypeID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var licenseType = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + licenseType.Validate(); + } + return licenseType; + } + ); + } + + /// + public Task> Retrieve( + string licenseTypeID, + LicenseTypeRetrieveParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.Retrieve(parameters with { LicenseTypeID = licenseTypeID }, cancellationToken); + } + + /// + public async Task> List( + LicenseTypeListParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var page = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + page.Validate(); + } + return new LicenseTypeListPage(this, parameters, page); + } + ); + } +} diff --git a/src/Orb/Services/Licenses/ExternalLicenseService.cs b/src/Orb/Services/Licenses/ExternalLicenseService.cs new file mode 100644 index 000000000..499369932 --- /dev/null +++ b/src/Orb/Services/Licenses/ExternalLicenseService.cs @@ -0,0 +1,134 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses.ExternalLicenses; + +namespace Orb.Services.Licenses; + +/// +public sealed class ExternalLicenseService : IExternalLicenseService +{ + readonly Lazy _withRawResponse; + + /// + public IExternalLicenseServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IOrbClient _client; + + /// + public IExternalLicenseService WithOptions(Func modifier) + { + return new ExternalLicenseService(this._client.WithOptions(modifier)); + } + + public ExternalLicenseService(IOrbClient client) + { + _client = client; + + _withRawResponse = new(() => + new ExternalLicenseServiceWithRawResponse(client.WithRawResponse) + ); + } + + /// + public async Task GetUsage( + ExternalLicenseGetUsageParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.GetUsage(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task GetUsage( + string externalLicenseID, + ExternalLicenseGetUsageParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.GetUsage( + parameters with + { + ExternalLicenseID = externalLicenseID, + }, + cancellationToken + ); + } +} + +/// +public sealed class ExternalLicenseServiceWithRawResponse : IExternalLicenseServiceWithRawResponse +{ + readonly IOrbClientWithRawResponse _client; + + /// + public IExternalLicenseServiceWithRawResponse WithOptions( + Func modifier + ) + { + return new ExternalLicenseServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public ExternalLicenseServiceWithRawResponse(IOrbClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> GetUsage( + ExternalLicenseGetUsageParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.ExternalLicenseID == null) + { + throw new OrbInvalidDataException("'parameters.ExternalLicenseID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public Task> GetUsage( + string externalLicenseID, + ExternalLicenseGetUsageParams parameters, + CancellationToken cancellationToken = default + ) + { + return this.GetUsage( + parameters with + { + ExternalLicenseID = externalLicenseID, + }, + cancellationToken + ); + } +} diff --git a/src/Orb/Services/Licenses/IExternalLicenseService.cs b/src/Orb/Services/Licenses/IExternalLicenseService.cs new file mode 100644 index 000000000..339aba801 --- /dev/null +++ b/src/Orb/Services/Licenses/IExternalLicenseService.cs @@ -0,0 +1,76 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Models.Licenses.ExternalLicenses; + +namespace Orb.Services.Licenses; + +/// +/// 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 interface IExternalLicenseService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IExternalLicenseServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IExternalLicenseService WithOptions(Func modifier); + + /// + /// Returns usage and remaining credits for a license identified by its external + /// license ID. + /// + /// Date range defaults to the current billing period if not specified. + /// + Task GetUsage( + ExternalLicenseGetUsageParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task GetUsage( + string externalLicenseID, + ExternalLicenseGetUsageParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IExternalLicenseServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IExternalLicenseServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `get /licenses/external_licenses/{external_license_id}/usage`, but is otherwise the + /// same as . + /// + Task> GetUsage( + ExternalLicenseGetUsageParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> GetUsage( + string externalLicenseID, + ExternalLicenseGetUsageParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/Orb/Services/Licenses/IUsageService.cs b/src/Orb/Services/Licenses/IUsageService.cs new file mode 100644 index 000000000..11e92cd61 --- /dev/null +++ b/src/Orb/Services/Licenses/IUsageService.cs @@ -0,0 +1,94 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Models.Licenses.Usage; + +namespace Orb.Services.Licenses; + +/// +/// 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 interface IUsageService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IUsageServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IUsageService WithOptions(Func modifier); + + /// + /// Returns usage and remaining credits for all licenses of a given type on a subscription. + /// + /// Date range defaults to the current billing period if not specified. + /// + Task GetAllUsage( + UsageGetAllUsageParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns usage and remaining credits for a specific license over a date range. + /// + /// Date range defaults to the current billing period if not specified. + /// + Task GetUsage( + UsageGetUsageParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task GetUsage( + string licenseID, + UsageGetUsageParams? parameters = null, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IUsageServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IUsageServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for `get /licenses/usage`, but is otherwise the + /// same as . + /// + Task> GetAllUsage( + UsageGetAllUsageParams parameters, + CancellationToken cancellationToken = default + ); + + /// + /// Returns a raw HTTP response for `get /licenses/{license_id}/usage`, but is otherwise the + /// same as . + /// + Task> GetUsage( + UsageGetUsageParams parameters, + CancellationToken cancellationToken = default + ); + + /// + Task> GetUsage( + string licenseID, + UsageGetUsageParams? parameters = null, + CancellationToken cancellationToken = default + ); +} diff --git a/src/Orb/Services/Licenses/UsageService.cs b/src/Orb/Services/Licenses/UsageService.cs new file mode 100644 index 000000000..50f073188 --- /dev/null +++ b/src/Orb/Services/Licenses/UsageService.cs @@ -0,0 +1,162 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Exceptions; +using Orb.Models.Licenses.Usage; + +namespace Orb.Services.Licenses; + +/// +public sealed class UsageService : IUsageService +{ + readonly Lazy _withRawResponse; + + /// + public IUsageServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IOrbClient _client; + + /// + public IUsageService WithOptions(Func modifier) + { + return new UsageService(this._client.WithOptions(modifier)); + } + + public UsageService(IOrbClient client) + { + _client = client; + + _withRawResponse = new(() => new UsageServiceWithRawResponse(client.WithRawResponse)); + } + + /// + public async Task GetAllUsage( + UsageGetAllUsageParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.GetAllUsage(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public async Task GetUsage( + UsageGetUsageParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.GetUsage(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public Task GetUsage( + string licenseID, + UsageGetUsageParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.GetUsage(parameters with { LicenseID = licenseID }, cancellationToken); + } +} + +/// +public sealed class UsageServiceWithRawResponse : IUsageServiceWithRawResponse +{ + readonly IOrbClientWithRawResponse _client; + + /// + public IUsageServiceWithRawResponse WithOptions(Func modifier) + { + return new UsageServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public UsageServiceWithRawResponse(IOrbClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> GetAllUsage( + UsageGetAllUsageParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public async Task> GetUsage( + UsageGetUsageParams parameters, + CancellationToken cancellationToken = default + ) + { + if (parameters.LicenseID == null) + { + throw new OrbInvalidDataException("'parameters.LicenseID' cannot be null"); + } + + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var deserializedResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + deserializedResponse.Validate(); + } + return deserializedResponse; + } + ); + } + + /// + public Task> GetUsage( + string licenseID, + UsageGetUsageParams? parameters = null, + CancellationToken cancellationToken = default + ) + { + parameters ??= new(); + + return this.GetUsage(parameters with { LicenseID = licenseID }, cancellationToken); + } +} From 4116c95ff4635a27f7e5132a3a17c413f4853efc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 16:50:06 +0000 Subject: [PATCH 23/39] feat(client): add equality and tostring for multipart data --- .../Core/MultipartJsonElementTest.cs | 210 ++++++++++++++++++ src/Orb/Core/ApiEnum.cs | 5 +- src/Orb/Core/FriendlyJsonPrinter.cs | 78 +++++++ src/Orb/Core/JsonDictionary.cs | 7 +- src/Orb/Core/MultipartJsonDictionary.cs | 36 ++- src/Orb/Core/MultipartJsonElement.cs | 114 ++++++++++ src/Orb/Models/AdjustmentInterval.cs | 5 +- .../Alerts/AlertCreateForCustomerParams.cs | 20 +- .../AlertCreateForExternalCustomerParams.cs | 22 +- .../AlertCreateForSubscriptionParams.cs | 20 +- src/Orb/Models/Alerts/AlertDisableParams.cs | 20 +- src/Orb/Models/Alerts/AlertEnableParams.cs | 20 +- src/Orb/Models/Alerts/AlertListPage.cs | 5 +- src/Orb/Models/Alerts/AlertListParams.cs | 16 +- src/Orb/Models/Alerts/AlertRetrieveParams.cs | 18 +- src/Orb/Models/Alerts/AlertUpdateParams.cs | 22 +- .../Beta/BetaCreatePlanVersionParams.cs | 100 +++++++-- .../Models/Beta/BetaFetchPlanVersionParams.cs | 20 +- .../Beta/BetaSetDefaultPlanVersionParams.cs | 20 +- .../ExternalPlanIDCreatePlanVersionParams.cs | 100 +++++++-- .../ExternalPlanIDFetchPlanVersionParams.cs | 20 +- ...ternalPlanIDSetDefaultPlanVersionParams.cs | 20 +- src/Orb/Models/Beta/PlanVersion.cs | 5 +- .../Models/ChangedSubscriptionResources.cs | 10 +- src/Orb/Models/Coupons/Coupon.cs | 5 +- src/Orb/Models/Coupons/CouponArchiveParams.cs | 18 +- src/Orb/Models/Coupons/CouponCreateParams.cs | 23 +- src/Orb/Models/Coupons/CouponFetchParams.cs | 18 +- src/Orb/Models/Coupons/CouponListPage.cs | 5 +- src/Orb/Models/Coupons/CouponListParams.cs | 16 +- .../Subscriptions/SubscriptionListPage.cs | 5 +- .../Subscriptions/SubscriptionListParams.cs | 18 +- .../CreditBlocks/CreditBlockDeleteParams.cs | 18 +- .../CreditBlockListInvoicesParams.cs | 18 +- .../CreditBlocks/CreditBlockRetrieveParams.cs | 18 +- .../CreditNotes/CreditNoteCreateParams.cs | 18 +- .../CreditNotes/CreditNoteFetchParams.cs | 18 +- .../Models/CreditNotes/CreditNoteListPage.cs | 5 +- .../CreditNotes/CreditNoteListParams.cs | 16 +- .../BalanceTransactionCreateParams.cs | 20 +- .../BalanceTransactionListPage.cs | 5 +- .../BalanceTransactionListParams.cs | 18 +- .../Costs/CostListByExternalIDParams.cs | 20 +- .../Models/Customers/Costs/CostListParams.cs | 18 +- .../Credits/CreditListByExternalIDPage.cs | 5 +- .../Credits/CreditListByExternalIDParams.cs | 20 +- .../Customers/Credits/CreditListPage.cs | 5 +- .../Customers/Credits/CreditListParams.cs | 18 +- .../LedgerCreateEntryByExternalIDParams.cs | 37 ++- .../LedgerCreateEntryByExternalIDResponse.cs | 5 +- .../Credits/Ledger/LedgerCreateEntryParams.cs | 35 ++- .../Ledger/LedgerCreateEntryResponse.cs | 5 +- .../Ledger/LedgerListByExternalIDPage.cs | 5 +- .../Ledger/LedgerListByExternalIDParams.cs | 20 +- .../Ledger/LedgerListByExternalIDResponse.cs | 5 +- .../Credits/Ledger/LedgerListPage.cs | 5 +- .../Credits/Ledger/LedgerListParams.cs | 18 +- .../Credits/Ledger/LedgerListResponse.cs | 5 +- .../TopUps/TopUpCreateByExternalIDParams.cs | 22 +- .../Credits/TopUps/TopUpCreateParams.cs | 20 +- .../TopUps/TopUpDeleteByExternalIDParams.cs | 22 +- .../Credits/TopUps/TopUpDeleteParams.cs | 20 +- .../TopUps/TopUpListByExternalIDPage.cs | 5 +- .../TopUps/TopUpListByExternalIDParams.cs | 20 +- .../Customers/Credits/TopUps/TopUpListPage.cs | 5 +- .../Credits/TopUps/TopUpListParams.cs | 18 +- .../Models/Customers/CustomerCreateParams.cs | 23 +- .../Models/Customers/CustomerDeleteParams.cs | 18 +- .../CustomerFetchByExternalIDParams.cs | 20 +- .../Models/Customers/CustomerFetchParams.cs | 18 +- src/Orb/Models/Customers/CustomerListPage.cs | 5 +- .../Models/Customers/CustomerListParams.cs | 16 +- ...dsFromGatewayByExternalCustomerIDParams.cs | 20 +- ...omerSyncPaymentMethodsFromGatewayParams.cs | 18 +- .../CustomerUpdateByExternalIDParams.cs | 25 ++- .../Models/Customers/CustomerUpdateParams.cs | 25 ++- .../DimensionalPriceGroupCreateParams.cs | 18 +- .../DimensionalPriceGroupListPage.cs | 5 +- .../DimensionalPriceGroupListParams.cs | 16 +- .../DimensionalPriceGroupRetrieveParams.cs | 20 +- .../DimensionalPriceGroupUpdateParams.cs | 22 +- ...alDimensionalPriceGroupIDRetrieveParams.cs | 20 +- ...rnalDimensionalPriceGroupIDUpdateParams.cs | 22 +- .../Events/Backfills/BackfillCloseParams.cs | 18 +- .../Events/Backfills/BackfillCreateParams.cs | 18 +- .../Events/Backfills/BackfillFetchParams.cs | 18 +- .../Events/Backfills/BackfillListPage.cs | 5 +- .../Events/Backfills/BackfillListParams.cs | 16 +- .../Events/Backfills/BackfillRevertParams.cs | 18 +- src/Orb/Models/Events/EventDeprecateParams.cs | 18 +- src/Orb/Models/Events/EventIngestParams.cs | 18 +- src/Orb/Models/Events/EventSearchParams.cs | 18 +- src/Orb/Models/Events/EventUpdateParams.cs | 20 +- .../Models/Events/Volume/VolumeListParams.cs | 16 +- src/Orb/Models/Invoice.cs | 10 +- src/Orb/Models/InvoiceLevelDiscount.cs | 5 +- .../InvoiceLineItemCreateParams.cs | 18 +- .../InvoiceLineItemCreateResponse.cs | 10 +- .../Models/Invoices/InvoiceCreateParams.cs | 23 +- .../Invoices/InvoiceDeleteLineItemParams.cs | 20 +- src/Orb/Models/Invoices/InvoiceFetchParams.cs | 18 +- .../Invoices/InvoiceFetchUpcomingParams.cs | 16 +- .../Invoices/InvoiceFetchUpcomingResponse.cs | 10 +- src/Orb/Models/Invoices/InvoiceIssueParams.cs | 20 +- .../Invoices/InvoiceIssueSummaryParams.cs | 20 +- src/Orb/Models/Invoices/InvoiceListPage.cs | 5 +- src/Orb/Models/Invoices/InvoiceListParams.cs | 16 +- .../Models/Invoices/InvoiceListSummaryPage.cs | 5 +- .../Invoices/InvoiceListSummaryParams.cs | 16 +- .../Models/Invoices/InvoiceMarkPaidParams.cs | 20 +- src/Orb/Models/Invoices/InvoicePayParams.cs | 18 +- .../Models/Invoices/InvoiceUpdateParams.cs | 30 ++- src/Orb/Models/Invoices/InvoiceVoidParams.cs | 18 +- src/Orb/Models/Items/ItemArchiveParams.cs | 18 +- src/Orb/Models/Items/ItemCreateParams.cs | 18 +- src/Orb/Models/Items/ItemFetchParams.cs | 18 +- src/Orb/Models/Items/ItemListPage.cs | 5 +- src/Orb/Models/Items/ItemListParams.cs | 16 +- src/Orb/Models/Items/ItemUpdateParams.cs | 20 +- .../LicenseTypes/LicenseTypeCreateParams.cs | 18 +- .../LicenseTypes/LicenseTypeListPage.cs | 5 +- .../LicenseTypes/LicenseTypeListParams.cs | 16 +- .../LicenseTypes/LicenseTypeRetrieveParams.cs | 18 +- .../ExternalLicenseGetUsageParams.cs | 20 +- .../Models/Licenses/LicenseCreateParams.cs | 18 +- .../Licenses/LicenseDeactivateParams.cs | 20 +- src/Orb/Models/Licenses/LicenseListPage.cs | 5 +- src/Orb/Models/Licenses/LicenseListParams.cs | 16 +- .../LicenseRetrieveByExternalIDParams.cs | 20 +- .../Models/Licenses/LicenseRetrieveParams.cs | 18 +- .../Licenses/Usage/UsageGetAllUsageParams.cs | 16 +- .../Licenses/Usage/UsageGetUsageParams.cs | 18 +- src/Orb/Models/Metrics/MetricCreateParams.cs | 18 +- src/Orb/Models/Metrics/MetricFetchParams.cs | 18 +- src/Orb/Models/Metrics/MetricListPage.cs | 5 +- src/Orb/Models/Metrics/MetricListParams.cs | 16 +- src/Orb/Models/Metrics/MetricUpdateParams.cs | 20 +- src/Orb/Models/NewFloatingBulkPrice.cs | 5 +- .../NewFloatingBulkWithProrationPrice.cs | 5 +- .../NewFloatingCumulativeGroupedBulkPrice.cs | 5 +- .../NewFloatingGroupedAllocationPrice.cs | 5 +- .../NewFloatingGroupedTieredPackagePrice.cs | 5 +- .../Models/NewFloatingGroupedTieredPrice.cs | 5 +- ...wFloatingGroupedWithMeteredMinimumPrice.cs | 5 +- ...FloatingGroupedWithProratedMinimumPrice.cs | 5 +- src/Orb/Models/NewFloatingMatrixPrice.cs | 5 +- .../NewFloatingMatrixWithAllocationPrice.cs | 5 +- .../NewFloatingMatrixWithDisplayNamePrice.cs | 5 +- .../NewFloatingMaxGroupTieredPackagePrice.cs | 5 +- .../NewFloatingMinimumCompositePrice.cs | 5 +- src/Orb/Models/NewFloatingPackagePrice.cs | 5 +- .../NewFloatingPackageWithAllocationPrice.cs | 5 +- ...ingScalableMatrixWithTieredPricingPrice.cs | 5 +- ...atingScalableMatrixWithUnitPricingPrice.cs | 5 +- .../NewFloatingThresholdTotalAmountPrice.cs | 5 +- .../Models/NewFloatingTieredPackagePrice.cs | 5 +- ...ewFloatingTieredPackageWithMinimumPrice.cs | 5 +- src/Orb/Models/NewFloatingTieredPrice.cs | 5 +- .../NewFloatingTieredWithMinimumPrice.cs | 5 +- .../NewFloatingTieredWithProrationPrice.cs | 5 +- src/Orb/Models/NewFloatingUnitPrice.cs | 5 +- .../Models/NewFloatingUnitWithPercentPrice.cs | 5 +- .../NewFloatingUnitWithProrationPrice.cs | 5 +- src/Orb/Models/NewPlanBulkPrice.cs | 5 +- .../Models/NewPlanBulkWithProrationPrice.cs | 5 +- .../NewPlanCumulativeGroupedBulkPrice.cs | 5 +- .../Models/NewPlanGroupedAllocationPrice.cs | 5 +- .../NewPlanGroupedTieredPackagePrice.cs | 5 +- src/Orb/Models/NewPlanGroupedTieredPrice.cs | 5 +- .../NewPlanGroupedWithMeteredMinimumPrice.cs | 5 +- .../NewPlanGroupedWithProratedMinimumPrice.cs | 5 +- src/Orb/Models/NewPlanMatrixPrice.cs | 5 +- .../NewPlanMatrixWithAllocationPrice.cs | 5 +- .../NewPlanMatrixWithDisplayNamePrice.cs | 5 +- .../NewPlanMaxGroupTieredPackagePrice.cs | 5 +- .../Models/NewPlanMinimumCompositePrice.cs | 5 +- src/Orb/Models/NewPlanPackagePrice.cs | 5 +- .../NewPlanPackageWithAllocationPrice.cs | 5 +- ...lanScalableMatrixWithTieredPricingPrice.cs | 5 +- ...wPlanScalableMatrixWithUnitPricingPrice.cs | 5 +- .../NewPlanThresholdTotalAmountPrice.cs | 5 +- src/Orb/Models/NewPlanTieredPackagePrice.cs | 5 +- .../NewPlanTieredPackageWithMinimumPrice.cs | 5 +- src/Orb/Models/NewPlanTieredPrice.cs | 5 +- .../Models/NewPlanTieredWithMinimumPrice.cs | 5 +- src/Orb/Models/NewPlanUnitPrice.cs | 5 +- src/Orb/Models/NewPlanUnitWithPercentPrice.cs | 5 +- .../Models/NewPlanUnitWithProrationPrice.cs | 5 +- .../ExternalPlanIDFetchParams.cs | 18 +- .../ExternalPlanIDUpdateParams.cs | 22 +- .../Plans/Migrations/MigrationCancelParams.cs | 20 +- .../Migrations/MigrationCancelResponse.cs | 5 +- .../Plans/Migrations/MigrationListPage.cs | 5 +- .../Plans/Migrations/MigrationListParams.cs | 18 +- .../Plans/Migrations/MigrationListResponse.cs | 5 +- .../Migrations/MigrationRetrieveParams.cs | 20 +- .../Migrations/MigrationRetrieveResponse.cs | 5 +- src/Orb/Models/Plans/Plan.cs | 5 +- src/Orb/Models/Plans/PlanCreateParams.cs | 58 +++-- src/Orb/Models/Plans/PlanFetchParams.cs | 18 +- src/Orb/Models/Plans/PlanListPage.cs | 5 +- src/Orb/Models/Plans/PlanListParams.cs | 16 +- src/Orb/Models/Plans/PlanUpdateParams.cs | 20 +- src/Orb/Models/Price.cs | 160 ++++++++++--- src/Orb/Models/Prices/EvaluatePriceGroup.cs | 5 +- .../ExternalPriceIDFetchParams.cs | 18 +- .../ExternalPriceIDUpdateParams.cs | 20 +- src/Orb/Models/Prices/PriceCreateParams.cs | 48 +++- .../Prices/PriceEvaluateMultipleParams.cs | 48 +++- src/Orb/Models/Prices/PriceEvaluateParams.cs | 20 +- .../PriceEvaluatePreviewEventsParams.cs | 48 +++- src/Orb/Models/Prices/PriceFetchParams.cs | 18 +- src/Orb/Models/Prices/PriceListPage.cs | 5 +- src/Orb/Models/Prices/PriceListParams.cs | 16 +- src/Orb/Models/Prices/PriceUpdateParams.cs | 20 +- src/Orb/Models/SharedDiscount.cs | 5 +- .../MutatedSubscription.cs | 5 +- .../SubscriptionChangeApplyParams.cs | 22 +- .../SubscriptionChangeCancelParams.cs | 20 +- .../SubscriptionChangeListPage.cs | 5 +- .../SubscriptionChangeListParams.cs | 16 +- .../SubscriptionChangeRetrieveParams.cs | 20 +- .../Subscriptions/NewSubscriptionBulkPrice.cs | 5 +- .../NewSubscriptionBulkWithProrationPrice.cs | 5 +- ...wSubscriptionCumulativeGroupedBulkPrice.cs | 5 +- .../NewSubscriptionGroupedAllocationPrice.cs | 5 +- ...ewSubscriptionGroupedTieredPackagePrice.cs | 5 +- .../NewSubscriptionGroupedTieredPrice.cs | 5 +- ...scriptionGroupedWithMeteredMinimumPrice.cs | 5 +- ...criptionGroupedWithProratedMinimumPrice.cs | 5 +- .../NewSubscriptionMatrixPrice.cs | 5 +- ...ewSubscriptionMatrixWithAllocationPrice.cs | 5 +- ...wSubscriptionMatrixWithDisplayNamePrice.cs | 5 +- ...wSubscriptionMaxGroupTieredPackagePrice.cs | 5 +- .../NewSubscriptionMinimumCompositePrice.cs | 5 +- .../NewSubscriptionPackagePrice.cs | 5 +- ...wSubscriptionPackageWithAllocationPrice.cs | 5 +- ...ionScalableMatrixWithTieredPricingPrice.cs | 5 +- ...ptionScalableMatrixWithUnitPricingPrice.cs | 5 +- ...ewSubscriptionThresholdTotalAmountPrice.cs | 5 +- .../NewSubscriptionTieredPackagePrice.cs | 5 +- ...bscriptionTieredPackageWithMinimumPrice.cs | 5 +- .../NewSubscriptionTieredPrice.cs | 5 +- .../NewSubscriptionTieredWithMinimumPrice.cs | 5 +- .../Subscriptions/NewSubscriptionUnitPrice.cs | 5 +- .../NewSubscriptionUnitWithPercentPrice.cs | 5 +- .../NewSubscriptionUnitWithProrationPrice.cs | 5 +- src/Orb/Models/Subscriptions/Subscription.cs | 5 +- .../Subscriptions/SubscriptionCancelParams.cs | 20 +- .../Subscriptions/SubscriptionCreateParams.cs | 98 ++++++-- .../SubscriptionFetchCostsParams.cs | 18 +- .../Subscriptions/SubscriptionFetchParams.cs | 18 +- .../SubscriptionFetchSchedulePage.cs | 5 +- .../SubscriptionFetchScheduleParams.cs | 18 +- .../SubscriptionFetchUsageParams.cs | 18 +- .../Subscriptions/SubscriptionListPage.cs | 5 +- .../Subscriptions/SubscriptionListParams.cs | 16 +- .../SubscriptionPriceIntervalsParams.cs | 100 +++++++-- .../SubscriptionRedeemCouponParams.cs | 20 +- .../SubscriptionSchedulePlanChangeParams.cs | 100 +++++++-- .../SubscriptionTriggerPhaseParams.cs | 20 +- ...ubscriptionUnscheduleCancellationParams.cs | 18 +- ...UnscheduleFixedFeeQuantityUpdatesParams.cs | 20 +- ...ptionUnschedulePendingPlanChangesParams.cs | 18 +- ...ubscriptionUpdateFixedFeeQuantityParams.cs | 20 +- .../Subscriptions/SubscriptionUpdateParams.cs | 20 +- .../SubscriptionUpdateTrialParams.cs | 25 ++- .../Models/Subscriptions/SubscriptionUsage.cs | 5 +- src/Orb/Models/TopLevel/TopLevelPingParams.cs | 16 +- 269 files changed, 3303 insertions(+), 1144 deletions(-) create mode 100644 src/Orb.Tests/Core/MultipartJsonElementTest.cs create mode 100644 src/Orb/Core/FriendlyJsonPrinter.cs diff --git a/src/Orb.Tests/Core/MultipartJsonElementTest.cs b/src/Orb.Tests/Core/MultipartJsonElementTest.cs new file mode 100644 index 000000000..2a5e2b98f --- /dev/null +++ b/src/Orb.Tests/Core/MultipartJsonElementTest.cs @@ -0,0 +1,210 @@ +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Tests.Core; + +public class MultipartJsonElementTest +{ + [Fact] + public void NumberAndNumberEqual_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement(3); + MultipartJsonElement b = JsonSerializer.SerializeToElement(3); + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void NumberAndNumberNotEqual_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement(3); + MultipartJsonElement b = JsonSerializer.SerializeToElement(4); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndStringEqual_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("text"); + MultipartJsonElement b = JsonSerializer.SerializeToElement("text"); + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndStringNotEqual_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("text"); + MultipartJsonElement b = JsonSerializer.SerializeToElement("test"); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndNumberNotEqual1_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("text"); + MultipartJsonElement b = JsonSerializer.SerializeToElement(3); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndNumberNotEqual1_Works1() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("text"); + MultipartJsonElement b = JsonSerializer.SerializeToElement(3); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void StringAndNumberNotEqual2_Works() + { + MultipartJsonElement a = JsonSerializer.SerializeToElement("3"); + MultipartJsonElement b = JsonSerializer.SerializeToElement(3); + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void BinaryContentEqual_Works() + { + BinaryContent content = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement(content); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement(content); + + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void BinaryContentDifferentReferencesNotEqual_Works() + { + BinaryContent contentA = Encoding.UTF8.GetBytes("text"); + BinaryContent contentB = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement(contentA); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement(contentB); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ArraysEqual_Works() + { + BinaryContent content1 = Encoding.UTF8.GetBytes("text"); + BinaryContent content2 = Encoding.UTF8.GetBytes("text"); + BinaryContent content3 = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2, content3 } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2, content3 } + ); + + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ArrayMissingElementNotEqual_Works() + { + BinaryContent content1 = Encoding.UTF8.GetBytes("text"); + BinaryContent content2 = Encoding.UTF8.GetBytes("text"); + BinaryContent content3 = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2, content3 } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2 } + ); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ArrayOutOfOrderNotEqual_Works() + { + BinaryContent content1 = Encoding.UTF8.GetBytes("text"); + BinaryContent content2 = Encoding.UTF8.GetBytes("text"); + BinaryContent content3 = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new List { content1, content2, content3 } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new List { content1, content3, content2 } + ); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ObjectsEqual_Works() + { + BinaryContent content = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + } + ); + + Assert.True(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ObjectExtraKeyNotEqual_Works() + { + BinaryContent content = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + { "extra", "test" }, + } + ); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } + + [Fact] + public void ObjectExtraKeyNotEqual_Works1() + { + BinaryContent content = Encoding.UTF8.GetBytes("text"); + + MultipartJsonElement a = MultipartJsonSerializer.SerializeToElement( + new Dictionary + { + { "string", "text" }, + { "number", -5 }, + { "binary", content }, + } + ); + MultipartJsonElement b = MultipartJsonSerializer.SerializeToElement( + new Dictionary { { "string", "text" }, { "binary", content } } + ); + + Assert.False(MultipartJsonElement.DeepEquals(a, b)); + } +} diff --git a/src/Orb/Core/ApiEnum.cs b/src/Orb/Core/ApiEnum.cs index 0d74d005b..9a5aac55c 100644 --- a/src/Orb/Core/ApiEnum.cs +++ b/src/Orb/Core/ApiEnum.cs @@ -95,7 +95,10 @@ public virtual bool Equals(ApiEnum? other) } public override string ToString() => - JsonSerializer.Serialize(this.Json, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); public override int GetHashCode() { diff --git a/src/Orb/Core/FriendlyJsonPrinter.cs b/src/Orb/Core/FriendlyJsonPrinter.cs new file mode 100644 index 000000000..9a927f3b7 --- /dev/null +++ b/src/Orb/Core/FriendlyJsonPrinter.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Orb.Core; + +static class FriendlyJsonPrinter +{ + public static JsonElement PrintValue(JsonElement value) => value; + + public static JsonElement PrintValue(IReadOnlyDictionary value) => + JsonSerializer.SerializeToElement(value); + + public static JsonElement PrintValue(IReadOnlyList value) => + JsonSerializer.SerializeToElement(value); + + public static JsonElement PrintValue(IReadOnlyDictionary value) + { + int binaryContentCount = 0; + var ret = new Dictionary(); + foreach (var item in value) + { + ret[item.Key] = PrintValue( + item.Value.Json, + item.Value.BinaryContents, + ref binaryContentCount + ); + } + return PrintValue(ret); + } + + public static JsonElement PrintValue(MultipartJsonElement value) + { + int binaryContentCount = 0; + return PrintValue(value.Json, value.BinaryContents, ref binaryContentCount); + } + + static JsonElement PrintValue( + JsonElement json, + IReadOnlyDictionary binaryContent, + ref int binaryContentCount + ) + { + switch (json.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + case JsonValueKind.Number: + case JsonValueKind.True: + case JsonValueKind.False: + return json; + case JsonValueKind.String: + return json.TryGetGuid(out var guid) && binaryContent.ContainsKey(guid) + ? JsonSerializer.SerializeToElement($"[Binary Content {binaryContentCount++}]") + : json; + case JsonValueKind.Object: + { + var ret = new Dictionary(); + foreach (var item in json.EnumerateObject()) + { + ret[item.Name] = PrintValue(item.Value, binaryContent, ref binaryContentCount); + } + return PrintValue(ret); + } + case JsonValueKind.Array: + { + var ret = new List(); + foreach (var item in json.EnumerateArray()) + { + ret.Add(PrintValue(item, binaryContent, ref binaryContentCount)); + } + return PrintValue(ret); + } + default: + throw new InvalidOperationException("Unreachable"); + } + } +} diff --git a/src/Orb/Core/JsonDictionary.cs b/src/Orb/Core/JsonDictionary.cs index 461dc7931..310da6fcf 100644 --- a/src/Orb/Core/JsonDictionary.cs +++ b/src/Orb/Core/JsonDictionary.cs @@ -19,7 +19,7 @@ namespace Orb.Core; /// sealed class JsonDictionary { - IDictionary _rawData; + IReadOnlyDictionary _rawData; readonly ConcurrentDictionary _deserializedData; @@ -186,7 +186,10 @@ public T GetNotNullStruct(string key) } public override string ToString() => - JsonSerializer.Serialize(this._rawData, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this._rawData), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Core/MultipartJsonDictionary.cs b/src/Orb/Core/MultipartJsonDictionary.cs index d948c008e..1c1500a3d 100644 --- a/src/Orb/Core/MultipartJsonDictionary.cs +++ b/src/Orb/Core/MultipartJsonDictionary.cs @@ -19,7 +19,7 @@ namespace Orb.Core; /// sealed class MultipartJsonDictionary { - IDictionary _rawData; + IReadOnlyDictionary _rawData; readonly ConcurrentDictionary _deserializedData; @@ -193,4 +193,38 @@ public T GetNotNullStruct(string key) _deserializedData[key] = deserialized; return deserialized; } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this._rawData), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not MultipartJsonDictionary other || _rawData.Count != other._rawData.Count) + { + return false; + } + + foreach (var item in _rawData) + { + if (!other._rawData.TryGetValue(item.Key, out var otherValue)) + { + return false; + } + + if (!MultipartJsonElement.DeepEquals(item.Value, otherValue)) + { + return false; + } + } + + return true; + } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Core/MultipartJsonElement.cs b/src/Orb/Core/MultipartJsonElement.cs index f16d3d504..63d7ab6fc 100644 --- a/src/Orb/Core/MultipartJsonElement.cs +++ b/src/Orb/Core/MultipartJsonElement.cs @@ -30,6 +30,120 @@ public readonly struct MultipartJsonElement() FrozenDictionary.ToFrozenDictionary(new Dictionary()); public static implicit operator MultipartJsonElement(JsonElement json) => new() { Json = json }; + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this), + ModelBase.ToStringSerializerOptions + ); + + public static bool DeepEquals(MultipartJsonElement a, MultipartJsonElement b) => + MultipartJsonElement.DeepEqualsInner(a.Json, a.BinaryContents, b.Json, b.BinaryContents); + + static bool DeepEqualsInner( + JsonElement jsonA, + IReadOnlyDictionary binaryA, + JsonElement jsonB, + IReadOnlyDictionary binaryB + ) + { + if (jsonA.ValueKind != jsonB.ValueKind) + { + return false; + } + + switch (jsonA.ValueKind) + { + case JsonValueKind.Undefined: + case JsonValueKind.Null: + case JsonValueKind.True: + case JsonValueKind.False: + return true; + case JsonValueKind.Number: + return JsonElement.DeepEquals(jsonA, jsonB); + case JsonValueKind.String: + BinaryContent? aContent = null; + + BinaryContent? bContent = null; + + if (jsonA.TryGetGuid(out var guidA) && binaryA.TryGetValue(guidA, out var a)) + { + aContent = a; + } + + if (jsonB.TryGetGuid(out var guidB) && binaryB.TryGetValue(guidB, out var b)) + { + bContent = b; + } + + if (aContent != null && bContent != null) + { + return aContent == bContent; + } + else if (aContent == null && bContent == null) + { + return jsonA.GetString() == jsonB.GetString(); + } + else + { + return false; + } + case JsonValueKind.Object: + Dictionary propertiesA = new(); + + foreach (var item1 in jsonA.EnumerateObject()) + { + propertiesA[item1.Name] = item1.Value; + } + + Dictionary propertiesB = new(); + + foreach (var item1 in jsonB.EnumerateObject()) + { + propertiesB[item1.Name] = item1.Value; + } + + if (propertiesA.Count != propertiesB.Count) + { + return false; + } + + foreach (var property in propertiesA) + { + if (!propertiesB.TryGetValue(property.Key, out var b1)) + { + return false; + } + + if (!MultipartJsonElement.DeepEqualsInner(property.Value, binaryA, b1, binaryB)) + { + return false; + } + } + + return true; + case JsonValueKind.Array: + if (jsonA.GetArrayLength() != jsonB.GetArrayLength()) + { + return false; + } + + var i = 0; + foreach (var item in jsonA.EnumerateArray()) + { + if (!MultipartJsonElement.DeepEqualsInner(item, binaryA, jsonB[i], binaryB)) + { + return false; + } + + i++; + } + + return true; + default: + throw new InvalidOperationException("Unreachable"); + } + } } /// diff --git a/src/Orb/Models/AdjustmentInterval.cs b/src/Orb/Models/AdjustmentInterval.cs index 6ad1e72b5..2f72e278c 100644 --- a/src/Orb/Models/AdjustmentInterval.cs +++ b/src/Orb/Models/AdjustmentInterval.cs @@ -506,7 +506,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs index 6f6dcb70b..186b6efc8 100644 --- a/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs +++ b/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs @@ -135,13 +135,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs index 69de9571f..d5fae8b4b 100644 --- a/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs +++ b/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs @@ -137,13 +137,21 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs b/src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs index 6fc4351eb..e3d2a8d5c 100644 --- a/src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs +++ b/src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs @@ -142,13 +142,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Alerts/AlertDisableParams.cs b/src/Orb/Models/Alerts/AlertDisableParams.cs index b1148f385..1eac104fb 100644 --- a/src/Orb/Models/Alerts/AlertDisableParams.cs +++ b/src/Orb/Models/Alerts/AlertDisableParams.cs @@ -80,12 +80,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["AlertConfigurationID"] = this.AlertConfigurationID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["AlertConfigurationID"] = JsonSerializer.SerializeToElement( + this.AlertConfigurationID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Alerts/AlertEnableParams.cs b/src/Orb/Models/Alerts/AlertEnableParams.cs index 50b9b152b..b83281d1f 100644 --- a/src/Orb/Models/Alerts/AlertEnableParams.cs +++ b/src/Orb/Models/Alerts/AlertEnableParams.cs @@ -80,12 +80,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["AlertConfigurationID"] = this.AlertConfigurationID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["AlertConfigurationID"] = JsonSerializer.SerializeToElement( + this.AlertConfigurationID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Alerts/AlertListPage.cs b/src/Orb/Models/Alerts/AlertListPage.cs index ff715af9b..5b78aba57 100644 --- a/src/Orb/Models/Alerts/AlertListPage.cs +++ b/src/Orb/Models/Alerts/AlertListPage.cs @@ -63,7 +63,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Alerts/AlertListParams.cs b/src/Orb/Models/Alerts/AlertListParams.cs index a6d9234b7..535f5bd4b 100644 --- a/src/Orb/Models/Alerts/AlertListParams.cs +++ b/src/Orb/Models/Alerts/AlertListParams.cs @@ -183,11 +183,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Alerts/AlertRetrieveParams.cs b/src/Orb/Models/Alerts/AlertRetrieveParams.cs index a23480b0b..c31e1ce1a 100644 --- a/src/Orb/Models/Alerts/AlertRetrieveParams.cs +++ b/src/Orb/Models/Alerts/AlertRetrieveParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["AlertID"] = this.AlertID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["AlertID"] = JsonSerializer.SerializeToElement(this.AlertID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Alerts/AlertUpdateParams.cs b/src/Orb/Models/Alerts/AlertUpdateParams.cs index 6e1e556c8..c852422ad 100644 --- a/src/Orb/Models/Alerts/AlertUpdateParams.cs +++ b/src/Orb/Models/Alerts/AlertUpdateParams.cs @@ -100,13 +100,21 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["AlertConfigurationID"] = JsonSerializer.SerializeToElement( + this.AlertConfigurationID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs index bc143cc1f..e3ea1b734 100644 --- a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs @@ -233,13 +233,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PlanID"] = JsonSerializer.SerializeToElement(this.PlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -699,7 +705,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2854,7 +2863,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4452,7 +4464,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5319,7 +5334,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6138,7 +6156,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6957,7 +6978,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7716,7 +7740,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -8512,7 +8539,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9193,7 +9223,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -11434,7 +11467,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -13118,7 +13154,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -14017,7 +14056,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -14855,7 +14897,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -15695,7 +15740,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -16477,7 +16525,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -17295,7 +17346,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs b/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs index 640bb60cd..523875a4a 100644 --- a/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs @@ -69,13 +69,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["PlanID"] = this.PlanID, - ["Version"] = this.Version, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PlanID"] = JsonSerializer.SerializeToElement(this.PlanID), + ["Version"] = JsonSerializer.SerializeToElement(this.Version), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs index 51329b2a2..c4bcb9333 100644 --- a/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs @@ -95,13 +95,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PlanID"] = JsonSerializer.SerializeToElement(this.PlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index ad8fd799e..041d6e1a4 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -235,13 +235,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalPlanID"] = JsonSerializer.SerializeToElement(this.ExternalPlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -701,7 +707,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2856,7 +2865,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4454,7 +4466,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5321,7 +5336,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6140,7 +6158,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6959,7 +6980,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7718,7 +7742,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -8514,7 +8541,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9195,7 +9225,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -11436,7 +11469,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -13120,7 +13156,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -14019,7 +14058,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -14857,7 +14899,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -15697,7 +15742,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -16479,7 +16527,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -17297,7 +17348,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs index dc5615885..a4554496b 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs @@ -71,13 +71,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalPlanID"] = this.ExternalPlanID, - ["Version"] = this.Version, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalPlanID"] = JsonSerializer.SerializeToElement(this.ExternalPlanID), + ["Version"] = JsonSerializer.SerializeToElement(this.Version), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs index 8f7fe53ed..2167719b5 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs @@ -95,13 +95,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalPlanID"] = JsonSerializer.SerializeToElement(this.ExternalPlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Beta/PlanVersion.cs b/src/Orb/Models/Beta/PlanVersion.cs index db45b8743..d98d6bbfa 100644 --- a/src/Orb/Models/Beta/PlanVersion.cs +++ b/src/Orb/Models/Beta/PlanVersion.cs @@ -563,7 +563,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/ChangedSubscriptionResources.cs b/src/Orb/Models/ChangedSubscriptionResources.cs index 92c8473fa..11cec3fea 100644 --- a/src/Orb/Models/ChangedSubscriptionResources.cs +++ b/src/Orb/Models/ChangedSubscriptionResources.cs @@ -2223,7 +2223,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2649,7 +2652,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Coupons/Coupon.cs b/src/Orb/Models/Coupons/Coupon.cs index 7b4a812d3..31b616e82 100644 --- a/src/Orb/Models/Coupons/Coupon.cs +++ b/src/Orb/Models/Coupons/Coupon.cs @@ -348,7 +348,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Coupons/CouponArchiveParams.cs b/src/Orb/Models/Coupons/CouponArchiveParams.cs index a54235c43..25442ff68 100644 --- a/src/Orb/Models/Coupons/CouponArchiveParams.cs +++ b/src/Orb/Models/Coupons/CouponArchiveParams.cs @@ -67,12 +67,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CouponID"] = this.CouponID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CouponID"] = JsonSerializer.SerializeToElement(this.CouponID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Coupons/CouponCreateParams.cs b/src/Orb/Models/Coupons/CouponCreateParams.cs index decab9de3..783b815c0 100644 --- a/src/Orb/Models/Coupons/CouponCreateParams.cs +++ b/src/Orb/Models/Coupons/CouponCreateParams.cs @@ -130,12 +130,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -364,7 +370,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Coupons/CouponFetchParams.cs b/src/Orb/Models/Coupons/CouponFetchParams.cs index f73172194..9df10a990 100644 --- a/src/Orb/Models/Coupons/CouponFetchParams.cs +++ b/src/Orb/Models/Coupons/CouponFetchParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CouponID"] = this.CouponID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CouponID"] = JsonSerializer.SerializeToElement(this.CouponID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Coupons/CouponListPage.cs b/src/Orb/Models/Coupons/CouponListPage.cs index bb70cdeaa..ef0181222 100644 --- a/src/Orb/Models/Coupons/CouponListPage.cs +++ b/src/Orb/Models/Coupons/CouponListPage.cs @@ -63,7 +63,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Coupons/CouponListParams.cs b/src/Orb/Models/Coupons/CouponListParams.cs index f01453c5c..639e563bb 100644 --- a/src/Orb/Models/Coupons/CouponListParams.cs +++ b/src/Orb/Models/Coupons/CouponListParams.cs @@ -126,11 +126,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs index c1aaa682f..f3ef2dae1 100644 --- a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs +++ b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs @@ -65,7 +65,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs index c527cbaa7..97241519d 100644 --- a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs +++ b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs @@ -103,12 +103,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CouponID"] = this.CouponID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CouponID"] = JsonSerializer.SerializeToElement(this.CouponID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs index 3a66a99a4..fe5ddf6aa 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs @@ -75,12 +75,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["BlockID"] = this.BlockID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BlockID"] = JsonSerializer.SerializeToElement(this.BlockID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs index c155b5276..859715280 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs @@ -80,12 +80,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["BlockID"] = this.BlockID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BlockID"] = JsonSerializer.SerializeToElement(this.BlockID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs index 0eda4b9fc..14a44931f 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["BlockID"] = this.BlockID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BlockID"] = JsonSerializer.SerializeToElement(this.BlockID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs index 92d95b4b4..2054ce4d5 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs @@ -179,12 +179,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs b/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs index 8a2eeaa91..5278e20d5 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CreditNoteID"] = this.CreditNoteID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CreditNoteID"] = JsonSerializer.SerializeToElement(this.CreditNoteID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/CreditNotes/CreditNoteListPage.cs b/src/Orb/Models/CreditNotes/CreditNoteListPage.cs index 26da4e4b6..7cd64396b 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteListPage.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/CreditNotes/CreditNoteListParams.cs b/src/Orb/Models/CreditNotes/CreditNoteListParams.cs index c53b8908c..38cd3cbd0 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteListParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteListParams.cs @@ -137,11 +137,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs index 2723f88e3..54086604a 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs @@ -120,13 +120,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs index 06faff421..fcb3a087a 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs @@ -66,7 +66,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs index 8538dac60..d2aee2f49 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs @@ -158,12 +158,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs b/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs index 9393c43ea..dbbf4197c 100644 --- a/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs @@ -217,12 +217,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalCustomerID"] = this.ExternalCustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Costs/CostListParams.cs b/src/Orb/Models/Customers/Costs/CostListParams.cs index 26d064cbe..37fe8f2c5 100644 --- a/src/Orb/Models/Customers/Costs/CostListParams.cs +++ b/src/Orb/Models/Customers/Costs/CostListParams.cs @@ -215,12 +215,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs index 12da703c9..45b80d900 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs @@ -66,7 +66,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs index 5ef576bdc..83931f69b 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs @@ -186,12 +186,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalCustomerID"] = this.ExternalCustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/CreditListPage.cs b/src/Orb/Models/Customers/Credits/CreditListPage.cs index 3826d7ee9..9380ce597 100644 --- a/src/Orb/Models/Customers/Credits/CreditListPage.cs +++ b/src/Orb/Models/Customers/Credits/CreditListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Customers/Credits/CreditListParams.cs b/src/Orb/Models/Customers/Credits/CreditListParams.cs index 7c7c9a295..ad81403b2 100644 --- a/src/Orb/Models/Customers/Credits/CreditListParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListParams.cs @@ -186,12 +186,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index f199ef27b..1d8c1a5f2 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -178,13 +178,21 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -668,7 +676,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1691,7 +1702,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1962,7 +1976,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs index a825ab432..c6f3c7b1b 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs @@ -638,7 +638,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index b27056180..36367c591 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -174,13 +174,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -615,7 +621,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1523,7 +1532,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1770,7 +1782,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs index 3c06ac95d..04ab956e5 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs @@ -616,7 +616,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs index 6a2506e05..056857986 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs @@ -66,7 +66,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs index b53d970c1..22cf1e569 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs @@ -251,12 +251,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalCustomerID"] = this.ExternalCustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs index 8a656ea54..061943cf3 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs @@ -626,7 +626,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs index 8c1fefdf3..7aa4cae8a 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs index 25e99de75..cdf4522e1 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs @@ -249,12 +249,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs index 871f87d03..fea2d00dc 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs @@ -610,7 +610,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs index ef541d4c2..de37211f0 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs @@ -201,13 +201,21 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs index 5f9b3e297..d2135c7fc 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs @@ -197,13 +197,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs index 108aa80b2..48d4443c9 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs @@ -71,13 +71,21 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalCustomerID"] = this.ExternalCustomerID, - ["TopUpID"] = this.TopUpID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["TopUpID"] = JsonSerializer.SerializeToElement(this.TopUpID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs index 6185f2930..efe5864e5 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs @@ -69,13 +69,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["TopUpID"] = this.TopUpID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["TopUpID"] = JsonSerializer.SerializeToElement(this.TopUpID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs index 2de906be9..7abeb4ac9 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs index 63e1fec26..3ff271a3e 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs @@ -100,12 +100,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalCustomerID"] = this.ExternalCustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs index 55438d709..3fa1dfdcb 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs index 2976230c6..3b9d3d428 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs @@ -100,12 +100,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/CustomerCreateParams.cs b/src/Orb/Models/Customers/CustomerCreateParams.cs index 8b96bcb3f..ec8add79a 100644 --- a/src/Orb/Models/Customers/CustomerCreateParams.cs +++ b/src/Orb/Models/Customers/CustomerCreateParams.cs @@ -472,12 +472,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -1174,7 +1180,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Customers/CustomerDeleteParams.cs b/src/Orb/Models/Customers/CustomerDeleteParams.cs index 005b9a5b6..3816edc4f 100644 --- a/src/Orb/Models/Customers/CustomerDeleteParams.cs +++ b/src/Orb/Models/Customers/CustomerDeleteParams.cs @@ -75,12 +75,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs index 75aae9203..4fa121192 100644 --- a/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs @@ -70,12 +70,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalCustomerID"] = this.ExternalCustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/CustomerFetchParams.cs b/src/Orb/Models/Customers/CustomerFetchParams.cs index 341e92334..215007d28 100644 --- a/src/Orb/Models/Customers/CustomerFetchParams.cs +++ b/src/Orb/Models/Customers/CustomerFetchParams.cs @@ -70,12 +70,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/CustomerListPage.cs b/src/Orb/Models/Customers/CustomerListPage.cs index f2ab7ea02..ff7eb3360 100644 --- a/src/Orb/Models/Customers/CustomerListPage.cs +++ b/src/Orb/Models/Customers/CustomerListPage.cs @@ -63,7 +63,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Customers/CustomerListParams.cs b/src/Orb/Models/Customers/CustomerListParams.cs index 2e7ed9177..53d89372c 100644 --- a/src/Orb/Models/Customers/CustomerListParams.cs +++ b/src/Orb/Models/Customers/CustomerListParams.cs @@ -139,11 +139,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs index 29778cac8..fcc3b81a5 100644 --- a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs +++ b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs @@ -73,12 +73,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalCustomerID"] = this.ExternalCustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs index d1630f40c..e4dc974be 100644 --- a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs +++ b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs @@ -72,12 +72,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["CustomerID"] = this.CustomerID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index c8ed516c2..b946455d7 100644 --- a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs @@ -462,13 +462,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -1260,7 +1266,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Customers/CustomerUpdateParams.cs b/src/Orb/Models/Customers/CustomerUpdateParams.cs index a9ec73d8e..b83718d6b 100644 --- a/src/Orb/Models/Customers/CustomerUpdateParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateParams.cs @@ -461,13 +461,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -1247,7 +1253,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs index 2796c58a7..f0e2ead9a 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs @@ -160,12 +160,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs index 62831e002..cbb065993 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs @@ -66,7 +66,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs index 6b10d0440..d6cd20146 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs @@ -97,11 +97,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs index c4227c5f7..92c1bd5fc 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs @@ -67,12 +67,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["DimensionalPriceGroupID"] = this.DimensionalPriceGroupID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["DimensionalPriceGroupID"] = JsonSerializer.SerializeToElement( + this.DimensionalPriceGroupID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs index 4da736eab..4302241cd 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs @@ -125,13 +125,21 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["DimensionalPriceGroupID"] = JsonSerializer.SerializeToElement( + this.DimensionalPriceGroupID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs index f3758a192..74e26db29 100644 --- a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs @@ -68,12 +68,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalDimensionalPriceGroupID"] = this.ExternalDimensionalPriceGroupID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalDimensionalPriceGroupID"] = JsonSerializer.SerializeToElement( + this.ExternalDimensionalPriceGroupID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs index 658a87ee3..5779efc6f 100644 --- a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs @@ -126,13 +126,21 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalDimensionalPriceGroupID"] = JsonSerializer.SerializeToElement( + this.ExternalDimensionalPriceGroupID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs b/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs index 0273ed5fb..f9f8aecd1 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs @@ -68,12 +68,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["BackfillID"] = this.BackfillID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BackfillID"] = JsonSerializer.SerializeToElement(this.BackfillID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs b/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs index da21ba31b..3c3243723 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs @@ -219,12 +219,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs b/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs index d843457ed..f944f40e1 100644 --- a/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["BackfillID"] = this.BackfillID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BackfillID"] = JsonSerializer.SerializeToElement(this.BackfillID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/Backfills/BackfillListPage.cs b/src/Orb/Models/Events/Backfills/BackfillListPage.cs index b8f3d9881..a5ef4e97c 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListPage.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Events/Backfills/BackfillListParams.cs b/src/Orb/Models/Events/Backfills/BackfillListParams.cs index 08526fa5b..d65c1430f 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListParams.cs @@ -100,11 +100,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs b/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs index 5c37076bb..c4f1ef481 100644 --- a/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs @@ -71,12 +71,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["BackfillID"] = this.BackfillID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BackfillID"] = JsonSerializer.SerializeToElement(this.BackfillID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/EventDeprecateParams.cs b/src/Orb/Models/Events/EventDeprecateParams.cs index 7354a41bc..b5ff6d266 100644 --- a/src/Orb/Models/Events/EventDeprecateParams.cs +++ b/src/Orb/Models/Events/EventDeprecateParams.cs @@ -97,12 +97,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["EventID"] = this.EventID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["EventID"] = JsonSerializer.SerializeToElement(this.EventID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/EventIngestParams.cs b/src/Orb/Models/Events/EventIngestParams.cs index 9cdbd6055..4f9f6c1b6 100644 --- a/src/Orb/Models/Events/EventIngestParams.cs +++ b/src/Orb/Models/Events/EventIngestParams.cs @@ -291,12 +291,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/EventSearchParams.cs b/src/Orb/Models/Events/EventSearchParams.cs index 7d9a29f1a..d129f2580 100644 --- a/src/Orb/Models/Events/EventSearchParams.cs +++ b/src/Orb/Models/Events/EventSearchParams.cs @@ -140,12 +140,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/EventUpdateParams.cs b/src/Orb/Models/Events/EventUpdateParams.cs index 2a935ae4a..9e9b0e775 100644 --- a/src/Orb/Models/Events/EventUpdateParams.cs +++ b/src/Orb/Models/Events/EventUpdateParams.cs @@ -193,13 +193,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["EventID"] = JsonSerializer.SerializeToElement(this.EventID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Events/Volume/VolumeListParams.cs b/src/Orb/Models/Events/Volume/VolumeListParams.cs index 8ab168de0..6ef1b06aa 100644 --- a/src/Orb/Models/Events/Volume/VolumeListParams.cs +++ b/src/Orb/Models/Events/Volume/VolumeListParams.cs @@ -144,11 +144,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoice.cs b/src/Orb/Models/Invoice.cs index e0b275ddc..2f620c274 100644 --- a/src/Orb/Models/Invoice.cs +++ b/src/Orb/Models/Invoice.cs @@ -2108,7 +2108,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2542,7 +2545,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/InvoiceLevelDiscount.cs b/src/Orb/Models/InvoiceLevelDiscount.cs index 2aab8015b..6f07cd8f8 100644 --- a/src/Orb/Models/InvoiceLevelDiscount.cs +++ b/src/Orb/Models/InvoiceLevelDiscount.cs @@ -249,7 +249,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs index c431ae916..6629ae01b 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs @@ -185,12 +185,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs index f82b54167..8364ff91d 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs @@ -725,7 +725,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1151,7 +1154,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Invoices/InvoiceCreateParams.cs b/src/Orb/Models/Invoices/InvoiceCreateParams.cs index 2f356be1e..dbdf29c80 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -256,12 +256,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -670,7 +676,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs b/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs index 3fc2cdbf1..93d7b5c8c 100644 --- a/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs +++ b/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs @@ -71,13 +71,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["InvoiceID"] = this.InvoiceID, - ["LineItemID"] = this.LineItemID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["LineItemID"] = JsonSerializer.SerializeToElement(this.LineItemID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoiceFetchParams.cs b/src/Orb/Models/Invoices/InvoiceFetchParams.cs index f9ad0653d..f89529bf0 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchParams.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["InvoiceID"] = this.InvoiceID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs index 9ee83d4ab..2507fb9fe 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs @@ -71,11 +71,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs index d9a84afa3..d96318111 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs @@ -2070,7 +2070,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -2496,7 +2499,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Invoices/InvoiceIssueParams.cs b/src/Orb/Models/Invoices/InvoiceIssueParams.cs index f2944617a..b66e56938 100644 --- a/src/Orb/Models/Invoices/InvoiceIssueParams.cs +++ b/src/Orb/Models/Invoices/InvoiceIssueParams.cs @@ -109,13 +109,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs index 7037cad33..987603c8d 100644 --- a/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs +++ b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs @@ -112,13 +112,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoiceListPage.cs b/src/Orb/Models/Invoices/InvoiceListPage.cs index a60ce1e17..afd25c4d2 100644 --- a/src/Orb/Models/Invoices/InvoiceListPage.cs +++ b/src/Orb/Models/Invoices/InvoiceListPage.cs @@ -63,7 +63,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Invoices/InvoiceListParams.cs b/src/Orb/Models/Invoices/InvoiceListParams.cs index ca97359be..24141e728 100644 --- a/src/Orb/Models/Invoices/InvoiceListParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListParams.cs @@ -297,11 +297,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs b/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs index 0f3108b6d..b20455466 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs index 128f14f52..76d564580 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs @@ -295,11 +295,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs b/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs index 616f3952a..5ee1ca72d 100644 --- a/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs +++ b/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs @@ -120,13 +120,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoicePayParams.cs b/src/Orb/Models/Invoices/InvoicePayParams.cs index 7026e0602..43e81ef1b 100644 --- a/src/Orb/Models/Invoices/InvoicePayParams.cs +++ b/src/Orb/Models/Invoices/InvoicePayParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["InvoiceID"] = this.InvoiceID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs index d9bab7336..c06a5a2bc 100644 --- a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs @@ -156,13 +156,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -405,7 +411,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -650,7 +659,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Invoices/InvoiceVoidParams.cs b/src/Orb/Models/Invoices/InvoiceVoidParams.cs index 04e8c6a76..22ddb2067 100644 --- a/src/Orb/Models/Invoices/InvoiceVoidParams.cs +++ b/src/Orb/Models/Invoices/InvoiceVoidParams.cs @@ -75,12 +75,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["InvoiceID"] = this.InvoiceID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Items/ItemArchiveParams.cs b/src/Orb/Models/Items/ItemArchiveParams.cs index 4b8cf9066..5415d4752 100644 --- a/src/Orb/Models/Items/ItemArchiveParams.cs +++ b/src/Orb/Models/Items/ItemArchiveParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ItemID"] = this.ItemID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ItemID"] = JsonSerializer.SerializeToElement(this.ItemID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Items/ItemCreateParams.cs b/src/Orb/Models/Items/ItemCreateParams.cs index d85df2e17..03f87b7d6 100644 --- a/src/Orb/Models/Items/ItemCreateParams.cs +++ b/src/Orb/Models/Items/ItemCreateParams.cs @@ -112,12 +112,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Items/ItemFetchParams.cs b/src/Orb/Models/Items/ItemFetchParams.cs index 119054224..aff0bcc4b 100644 --- a/src/Orb/Models/Items/ItemFetchParams.cs +++ b/src/Orb/Models/Items/ItemFetchParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ItemID"] = this.ItemID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ItemID"] = JsonSerializer.SerializeToElement(this.ItemID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Items/ItemListPage.cs b/src/Orb/Models/Items/ItemListPage.cs index 01dfc62f2..1918e973d 100644 --- a/src/Orb/Models/Items/ItemListPage.cs +++ b/src/Orb/Models/Items/ItemListPage.cs @@ -63,7 +63,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Items/ItemListParams.cs b/src/Orb/Models/Items/ItemListParams.cs index d08e7a2eb..e3db73528 100644 --- a/src/Orb/Models/Items/ItemListParams.cs +++ b/src/Orb/Models/Items/ItemListParams.cs @@ -95,11 +95,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Items/ItemUpdateParams.cs b/src/Orb/Models/Items/ItemUpdateParams.cs index d30c3e356..6eff09064 100644 --- a/src/Orb/Models/Items/ItemUpdateParams.cs +++ b/src/Orb/Models/Items/ItemUpdateParams.cs @@ -134,13 +134,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ItemID"] = JsonSerializer.SerializeToElement(this.ItemID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs index 9f769cd21..b42d63681 100644 --- a/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs +++ b/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs @@ -107,12 +107,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs index 84d4b8b9e..c8553b9b2 100644 --- a/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs index 153b7afc1..003152120 100644 --- a/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs @@ -100,11 +100,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs index b7f266c52..b949fb1fe 100644 --- a/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs +++ b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs @@ -68,12 +68,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["LicenseTypeID"] = this.LicenseTypeID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["LicenseTypeID"] = JsonSerializer.SerializeToElement(this.LicenseTypeID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs index 6a0c4d15e..17c9584ab 100644 --- a/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs +++ b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs @@ -178,12 +178,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalLicenseID"] = this.ExternalLicenseID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalLicenseID"] = JsonSerializer.SerializeToElement( + this.ExternalLicenseID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Licenses/LicenseCreateParams.cs b/src/Orb/Models/Licenses/LicenseCreateParams.cs index 8b332eb3c..8bd55b0a1 100644 --- a/src/Orb/Models/Licenses/LicenseCreateParams.cs +++ b/src/Orb/Models/Licenses/LicenseCreateParams.cs @@ -141,12 +141,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Licenses/LicenseDeactivateParams.cs b/src/Orb/Models/Licenses/LicenseDeactivateParams.cs index 4369411ae..207fac364 100644 --- a/src/Orb/Models/Licenses/LicenseDeactivateParams.cs +++ b/src/Orb/Models/Licenses/LicenseDeactivateParams.cs @@ -98,13 +98,19 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["LicenseID"] = this.LicenseID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["LicenseID"] = JsonSerializer.SerializeToElement(this.LicenseID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Licenses/LicenseListPage.cs b/src/Orb/Models/Licenses/LicenseListPage.cs index 43945bcd0..90a608a0c 100644 --- a/src/Orb/Models/Licenses/LicenseListPage.cs +++ b/src/Orb/Models/Licenses/LicenseListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Licenses/LicenseListParams.cs b/src/Orb/Models/Licenses/LicenseListParams.cs index 867670aff..56b953117 100644 --- a/src/Orb/Models/Licenses/LicenseListParams.cs +++ b/src/Orb/Models/Licenses/LicenseListParams.cs @@ -137,11 +137,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs index a833a9221..0aac2b226 100644 --- a/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs +++ b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs @@ -93,12 +93,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalLicenseID"] = this.ExternalLicenseID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalLicenseID"] = JsonSerializer.SerializeToElement( + this.ExternalLicenseID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Licenses/LicenseRetrieveParams.cs b/src/Orb/Models/Licenses/LicenseRetrieveParams.cs index 5e74714f6..904792843 100644 --- a/src/Orb/Models/Licenses/LicenseRetrieveParams.cs +++ b/src/Orb/Models/Licenses/LicenseRetrieveParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["LicenseID"] = this.LicenseID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["LicenseID"] = JsonSerializer.SerializeToElement(this.LicenseID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs index 792d3000e..643c518f1 100644 --- a/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs +++ b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs @@ -170,11 +170,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs b/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs index d0d7f0dde..3b2ecc776 100644 --- a/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs +++ b/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs @@ -149,12 +149,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["LicenseID"] = this.LicenseID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["LicenseID"] = JsonSerializer.SerializeToElement(this.LicenseID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Metrics/MetricCreateParams.cs b/src/Orb/Models/Metrics/MetricCreateParams.cs index dfab3ac8d..b54cfaa05 100644 --- a/src/Orb/Models/Metrics/MetricCreateParams.cs +++ b/src/Orb/Models/Metrics/MetricCreateParams.cs @@ -153,12 +153,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Metrics/MetricFetchParams.cs b/src/Orb/Models/Metrics/MetricFetchParams.cs index 09e5e1eb8..e2aa73dca 100644 --- a/src/Orb/Models/Metrics/MetricFetchParams.cs +++ b/src/Orb/Models/Metrics/MetricFetchParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["MetricID"] = this.MetricID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["MetricID"] = JsonSerializer.SerializeToElement(this.MetricID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Metrics/MetricListPage.cs b/src/Orb/Models/Metrics/MetricListPage.cs index 718def11c..e6f7cd2b5 100644 --- a/src/Orb/Models/Metrics/MetricListPage.cs +++ b/src/Orb/Models/Metrics/MetricListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Metrics/MetricListParams.cs b/src/Orb/Models/Metrics/MetricListParams.cs index 73712145e..d82f93b08 100644 --- a/src/Orb/Models/Metrics/MetricListParams.cs +++ b/src/Orb/Models/Metrics/MetricListParams.cs @@ -137,11 +137,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Metrics/MetricUpdateParams.cs b/src/Orb/Models/Metrics/MetricUpdateParams.cs index 2aefc20eb..e55fa9897 100644 --- a/src/Orb/Models/Metrics/MetricUpdateParams.cs +++ b/src/Orb/Models/Metrics/MetricUpdateParams.cs @@ -104,13 +104,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["MetricID"] = JsonSerializer.SerializeToElement(this.MetricID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/NewFloatingBulkPrice.cs b/src/Orb/Models/NewFloatingBulkPrice.cs index f034a5d69..99543a224 100644 --- a/src/Orb/Models/NewFloatingBulkPrice.cs +++ b/src/Orb/Models/NewFloatingBulkPrice.cs @@ -620,7 +620,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs index 83c922c42..524dd6717 100644 --- a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs @@ -805,7 +805,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs index 573b41a9c..fee49ca4a 100644 --- a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs @@ -822,7 +822,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs index 622ae6ca4..2c51df5dc 100644 --- a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs @@ -735,7 +735,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs index 2407ac8a2..c505df50c 100644 --- a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs @@ -830,7 +830,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs index efdeb94d4..8acfc818d 100644 --- a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs @@ -798,7 +798,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs index 5e3bcd140..2a7d0b7b2 100644 --- a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs @@ -950,7 +950,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs index 45eee68e7..cb4286dce 100644 --- a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs @@ -748,7 +748,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingMatrixPrice.cs b/src/Orb/Models/NewFloatingMatrixPrice.cs index 8812a9bd8..565360bc1 100644 --- a/src/Orb/Models/NewFloatingMatrixPrice.cs +++ b/src/Orb/Models/NewFloatingMatrixPrice.cs @@ -633,7 +633,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs index 684e77d27..4e1266ebd 100644 --- a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs @@ -646,7 +646,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs index 9310d2ff6..da0e3954a 100644 --- a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs @@ -836,7 +836,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs index ce3829815..36add6511 100644 --- a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs @@ -829,7 +829,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs index eb62b0d52..b8e2a0ec2 100644 --- a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs +++ b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs @@ -735,7 +735,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingPackagePrice.cs b/src/Orb/Models/NewFloatingPackagePrice.cs index 91b6d0c83..433f9fc63 100644 --- a/src/Orb/Models/NewFloatingPackagePrice.cs +++ b/src/Orb/Models/NewFloatingPackagePrice.cs @@ -633,7 +633,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs index 1a292a3cd..52159148b 100644 --- a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs +++ b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs @@ -730,7 +730,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs index 3eff528fe..ae76e46ab 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs @@ -950,7 +950,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs index 7ce662598..6e5dbbfc1 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs @@ -884,7 +884,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs index dbc4b7e62..f872dbf16 100644 --- a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs @@ -818,7 +818,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingTieredPackagePrice.cs b/src/Orb/Models/NewFloatingTieredPackagePrice.cs index fc3b001b2..6d76e8ac9 100644 --- a/src/Orb/Models/NewFloatingTieredPackagePrice.cs +++ b/src/Orb/Models/NewFloatingTieredPackagePrice.cs @@ -798,7 +798,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs index be8baccef..bc4f3f7fd 100644 --- a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs @@ -833,7 +833,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingTieredPrice.cs b/src/Orb/Models/NewFloatingTieredPrice.cs index e2461de80..11a7211fc 100644 --- a/src/Orb/Models/NewFloatingTieredPrice.cs +++ b/src/Orb/Models/NewFloatingTieredPrice.cs @@ -633,7 +633,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs index 35cbcb328..93a5fb2df 100644 --- a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs +++ b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs @@ -858,7 +858,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs index c7b4faead..14ae918be 100644 --- a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs @@ -811,7 +811,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingUnitPrice.cs b/src/Orb/Models/NewFloatingUnitPrice.cs index d31769474..30799101d 100644 --- a/src/Orb/Models/NewFloatingUnitPrice.cs +++ b/src/Orb/Models/NewFloatingUnitPrice.cs @@ -632,7 +632,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs index 2c95991cd..b7fc477d5 100644 --- a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs +++ b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs @@ -718,7 +718,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs index 8c7fe21e9..f99519846 100644 --- a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs +++ b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs @@ -714,7 +714,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanBulkPrice.cs b/src/Orb/Models/NewPlanBulkPrice.cs index 6a0a980a1..8f6845d2a 100644 --- a/src/Orb/Models/NewPlanBulkPrice.cs +++ b/src/Orb/Models/NewPlanBulkPrice.cs @@ -647,7 +647,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs index 999911571..594951c74 100644 --- a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs +++ b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs @@ -847,7 +847,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs index 96133fa2d..13f1796e8 100644 --- a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs @@ -865,7 +865,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs index 767228762..69092c99f 100644 --- a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs +++ b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs @@ -759,7 +759,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs index c772bf2a3..3bf39bab7 100644 --- a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs @@ -860,7 +860,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanGroupedTieredPrice.cs b/src/Orb/Models/NewPlanGroupedTieredPrice.cs index 30bee9235..99151c805 100644 --- a/src/Orb/Models/NewPlanGroupedTieredPrice.cs +++ b/src/Orb/Models/NewPlanGroupedTieredPrice.cs @@ -837,7 +837,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs index 04a942e4e..bf922c8a3 100644 --- a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs @@ -1012,7 +1012,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs index 31d982092..9af79b439 100644 --- a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs @@ -769,7 +769,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanMatrixPrice.cs b/src/Orb/Models/NewPlanMatrixPrice.cs index d64d9252b..35a4bb8a6 100644 --- a/src/Orb/Models/NewPlanMatrixPrice.cs +++ b/src/Orb/Models/NewPlanMatrixPrice.cs @@ -647,7 +647,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs index 34301621a..3e107b24f 100644 --- a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs @@ -661,7 +661,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs index cc880fdab..e2af5fbd8 100644 --- a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs @@ -868,7 +868,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs index ae0bd1cd2..4ae03ff60 100644 --- a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs @@ -859,7 +859,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanMinimumCompositePrice.cs b/src/Orb/Models/NewPlanMinimumCompositePrice.cs index a8d253b8f..009bf292a 100644 --- a/src/Orb/Models/NewPlanMinimumCompositePrice.cs +++ b/src/Orb/Models/NewPlanMinimumCompositePrice.cs @@ -758,7 +758,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanPackagePrice.cs b/src/Orb/Models/NewPlanPackagePrice.cs index 2f284fde9..4dd509cb7 100644 --- a/src/Orb/Models/NewPlanPackagePrice.cs +++ b/src/Orb/Models/NewPlanPackagePrice.cs @@ -647,7 +647,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs index df7cd6be2..8c3b564b8 100644 --- a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs +++ b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs @@ -755,7 +755,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs index 3348e8422..1af581809 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs @@ -995,7 +995,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs index 39032666a..42e143de5 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs @@ -913,7 +913,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs index 1ec898586..549491ed8 100644 --- a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs @@ -861,7 +861,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanTieredPackagePrice.cs b/src/Orb/Models/NewPlanTieredPackagePrice.cs index 704fd8a62..8d64e73de 100644 --- a/src/Orb/Models/NewPlanTieredPackagePrice.cs +++ b/src/Orb/Models/NewPlanTieredPackagePrice.cs @@ -837,7 +837,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs index 85ed66581..07a30325b 100644 --- a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs @@ -862,7 +862,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanTieredPrice.cs b/src/Orb/Models/NewPlanTieredPrice.cs index 23e81bb16..09b829fa3 100644 --- a/src/Orb/Models/NewPlanTieredPrice.cs +++ b/src/Orb/Models/NewPlanTieredPrice.cs @@ -647,7 +647,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs index 5150e160d..bf5704e33 100644 --- a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs +++ b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs @@ -893,7 +893,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanUnitPrice.cs b/src/Orb/Models/NewPlanUnitPrice.cs index 2413c718f..53e74bb28 100644 --- a/src/Orb/Models/NewPlanUnitPrice.cs +++ b/src/Orb/Models/NewPlanUnitPrice.cs @@ -647,7 +647,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs index a40dbc60b..69a5ac116 100644 --- a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs +++ b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs @@ -741,7 +741,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs index 6908028b4..91a2adfc4 100644 --- a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs +++ b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs @@ -738,7 +738,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs index 3a0f2d760..5ce6fefb5 100644 --- a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs +++ b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs @@ -78,12 +78,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalPlanID"] = this.ExternalPlanID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalPlanID"] = JsonSerializer.SerializeToElement(this.ExternalPlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs index 82034fc86..0671158bd 100644 --- a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs +++ b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs @@ -121,13 +121,21 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["OtherExternalPlanID"] = JsonSerializer.SerializeToElement( + this.OtherExternalPlanID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs index ead288e42..e09dca740 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs @@ -68,13 +68,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["PlanID"] = this.PlanID, - ["MigrationID"] = this.MigrationID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PlanID"] = JsonSerializer.SerializeToElement(this.PlanID), + ["MigrationID"] = JsonSerializer.SerializeToElement(this.MigrationID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs index 5b869ca27..032fe45c5 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs @@ -358,7 +358,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Plans/Migrations/MigrationListPage.cs b/src/Orb/Models/Plans/Migrations/MigrationListPage.cs index f6bf5e22d..72e56f689 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListPage.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListPage.cs @@ -64,7 +64,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationListParams.cs b/src/Orb/Models/Plans/Migrations/MigrationListParams.cs index e215d2f6e..5b2708f89 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListParams.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListParams.cs @@ -103,12 +103,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["PlanID"] = this.PlanID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PlanID"] = JsonSerializer.SerializeToElement(this.PlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs index 6dfb47e31..00a80b478 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs @@ -357,7 +357,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs index f336a58f9..c8043498b 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs @@ -68,13 +68,19 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["PlanID"] = this.PlanID, - ["MigrationID"] = this.MigrationID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PlanID"] = JsonSerializer.SerializeToElement(this.PlanID), + ["MigrationID"] = JsonSerializer.SerializeToElement(this.MigrationID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs index bfaf12781..1298672a5 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs @@ -328,7 +328,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Plans/Plan.cs b/src/Orb/Models/Plans/Plan.cs index cb3b98f2f..c529d290f 100644 --- a/src/Orb/Models/Plans/Plan.cs +++ b/src/Orb/Models/Plans/Plan.cs @@ -824,7 +824,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Plans/PlanCreateParams.cs b/src/Orb/Models/Plans/PlanCreateParams.cs index c65baa4c9..c2cf8b7da 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -245,12 +245,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -2305,7 +2311,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3907,7 +3916,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4774,7 +4786,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5593,7 +5608,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6412,7 +6430,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7171,7 +7192,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7967,7 +7991,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -8478,7 +8505,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Plans/PlanFetchParams.cs b/src/Orb/Models/Plans/PlanFetchParams.cs index fe3a4fd99..f5c596944 100644 --- a/src/Orb/Models/Plans/PlanFetchParams.cs +++ b/src/Orb/Models/Plans/PlanFetchParams.cs @@ -75,12 +75,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["PlanID"] = this.PlanID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PlanID"] = JsonSerializer.SerializeToElement(this.PlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Plans/PlanListPage.cs b/src/Orb/Models/Plans/PlanListPage.cs index a8ff248d2..f502c3bc8 100644 --- a/src/Orb/Models/Plans/PlanListPage.cs +++ b/src/Orb/Models/Plans/PlanListPage.cs @@ -63,7 +63,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Plans/PlanListParams.cs b/src/Orb/Models/Plans/PlanListParams.cs index e59161cb2..f0ac3f9a6 100644 --- a/src/Orb/Models/Plans/PlanListParams.cs +++ b/src/Orb/Models/Plans/PlanListParams.cs @@ -163,11 +163,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Plans/PlanUpdateParams.cs b/src/Orb/Models/Plans/PlanUpdateParams.cs index 1f6d6f5aa..7938bf877 100644 --- a/src/Orb/Models/Plans/PlanUpdateParams.cs +++ b/src/Orb/Models/Plans/PlanUpdateParams.cs @@ -121,13 +121,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PlanID"] = JsonSerializer.SerializeToElement(this.PlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index 144137313..f2c720976 100644 --- a/src/Orb/Models/Price.cs +++ b/src/Orb/Models/Price.cs @@ -2163,7 +2163,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3830,7 +3833,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5005,7 +5011,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6179,7 +6188,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7632,7 +7644,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -8813,7 +8828,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9990,7 +10008,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -11190,7 +11211,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -12584,7 +12608,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -13961,7 +13988,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -15389,7 +15419,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -16776,7 +16809,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -18177,7 +18213,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -19471,7 +19510,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -20760,7 +20802,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -21965,7 +22010,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -23351,7 +23399,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -24631,7 +24682,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -26119,7 +26173,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -27329,7 +27386,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -28649,7 +28709,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -30213,7 +30276,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -31536,7 +31602,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -32945,7 +33014,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -34350,7 +34422,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -35766,7 +35841,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -37237,7 +37315,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -38776,7 +38857,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -40192,7 +40276,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -41511,7 +41598,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -42792,7 +42882,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -44048,7 +44141,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Prices/EvaluatePriceGroup.cs b/src/Orb/Models/Prices/EvaluatePriceGroup.cs index beddf3325..e873474ad 100644 --- a/src/Orb/Models/Prices/EvaluatePriceGroup.cs +++ b/src/Orb/Models/Prices/EvaluatePriceGroup.cs @@ -329,7 +329,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs index 8f318c9cf..4759202b9 100644 --- a/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs +++ b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["ExternalPriceID"] = this.ExternalPriceID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalPriceID"] = JsonSerializer.SerializeToElement(this.ExternalPriceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs index e553d5356..88b44c125 100644 --- a/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs +++ b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs @@ -104,13 +104,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalPriceID"] = JsonSerializer.SerializeToElement(this.ExternalPriceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Prices/PriceCreateParams.cs b/src/Orb/Models/Prices/PriceCreateParams.cs index a68943402..86c6df858 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -101,12 +101,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -2078,7 +2084,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3668,7 +3677,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4470,7 +4482,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5273,7 +5288,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6016,7 +6034,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6796,7 +6817,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs index ffc95c951..70ad1f8fc 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -182,12 +182,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -2252,7 +2258,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3906,7 +3915,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4721,7 +4733,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5536,7 +5551,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6284,7 +6302,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7079,7 +7100,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Prices/PriceEvaluateParams.cs b/src/Orb/Models/Prices/PriceEvaluateParams.cs index c3aa1822e..b315a5b72 100644 --- a/src/Orb/Models/Prices/PriceEvaluateParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateParams.cs @@ -194,13 +194,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PriceID"] = JsonSerializer.SerializeToElement(this.PriceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs index 4ab1cced3..aef8c60b9 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs @@ -197,12 +197,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -2588,7 +2594,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -4326,7 +4335,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5187,7 +5199,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6048,7 +6063,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6851,7 +6869,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7701,7 +7722,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Prices/PriceFetchParams.cs b/src/Orb/Models/Prices/PriceFetchParams.cs index e6bb466a8..7f824500e 100644 --- a/src/Orb/Models/Prices/PriceFetchParams.cs +++ b/src/Orb/Models/Prices/PriceFetchParams.cs @@ -65,12 +65,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["PriceID"] = this.PriceID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PriceID"] = JsonSerializer.SerializeToElement(this.PriceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Prices/PriceListPage.cs b/src/Orb/Models/Prices/PriceListPage.cs index 51d3b5a00..f0366c21f 100644 --- a/src/Orb/Models/Prices/PriceListPage.cs +++ b/src/Orb/Models/Prices/PriceListPage.cs @@ -65,7 +65,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Prices/PriceListParams.cs b/src/Orb/Models/Prices/PriceListParams.cs index a37eb9489..d9591c483 100644 --- a/src/Orb/Models/Prices/PriceListParams.cs +++ b/src/Orb/Models/Prices/PriceListParams.cs @@ -95,11 +95,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Prices/PriceUpdateParams.cs b/src/Orb/Models/Prices/PriceUpdateParams.cs index 8d4b9c21c..4a0cc3f6c 100644 --- a/src/Orb/Models/Prices/PriceUpdateParams.cs +++ b/src/Orb/Models/Prices/PriceUpdateParams.cs @@ -104,13 +104,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["PriceID"] = JsonSerializer.SerializeToElement(this.PriceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/SharedDiscount.cs b/src/Orb/Models/SharedDiscount.cs index 5da3ce72d..183cf9732 100644 --- a/src/Orb/Models/SharedDiscount.cs +++ b/src/Orb/Models/SharedDiscount.cs @@ -286,7 +286,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs b/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs index 51715ba27..5f502396d 100644 --- a/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs +++ b/src/Orb/Models/SubscriptionChanges/MutatedSubscription.cs @@ -813,7 +813,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs index 04d739ee1..8fee129df 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs @@ -166,13 +166,21 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionChangeID"] = JsonSerializer.SerializeToElement( + this.SubscriptionChangeID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs index dd84813b7..bb143c890 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs @@ -69,12 +69,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["SubscriptionChangeID"] = this.SubscriptionChangeID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionChangeID"] = JsonSerializer.SerializeToElement( + this.SubscriptionChangeID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs index d231fcbc3..1977e299b 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs @@ -66,7 +66,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs index d6730c4e6..9d9516f0c 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs @@ -129,11 +129,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs index 63cc31aa3..051f587f5 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs @@ -73,12 +73,20 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["SubscriptionChangeID"] = this.SubscriptionChangeID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionChangeID"] = JsonSerializer.SerializeToElement( + this.SubscriptionChangeID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs index a6445dd23..b0f2a7b8b 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs @@ -649,7 +649,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs index 52f2a0285..4f0cd4bb1 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs @@ -830,7 +830,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs index 258d48185..edcd7e4a4 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs @@ -842,7 +842,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs index 4edada7bf..168dc87b3 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs @@ -753,7 +753,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs index d15a794a5..31e34dd78 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs @@ -850,7 +850,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs index c0b3f3184..2e433f033 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs @@ -817,7 +817,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs index 3e441f5d2..89acb4cc6 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs @@ -969,7 +969,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs index 7cf45eab2..f5450a3a6 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs @@ -767,7 +767,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs index 81bcdf606..86842754b 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs @@ -652,7 +652,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs index 84a692050..30f490d68 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs @@ -666,7 +666,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs index 90d900c22..9086a1ee0 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs @@ -856,7 +856,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs index b5b5960a3..1b98e3244 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs @@ -849,7 +849,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs index 750f7e3ae..5669ec462 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs @@ -753,7 +753,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs index 8b8772c66..e99d5e173 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs @@ -652,7 +652,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs index 43aa7b301..f592bbcf9 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs @@ -750,7 +750,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs index 4848de524..4d8ff102f 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs @@ -975,7 +975,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs index b8e36562f..8d2fc7720 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs @@ -909,7 +909,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs index d0784335c..2aa54ece7 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs @@ -838,7 +838,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs index 19417c32b..19de0a088 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs @@ -817,7 +817,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs index dcfe83272..ed5a352d9 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs @@ -849,7 +849,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs index 7e6aae968..6e9a3be7b 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs @@ -652,7 +652,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs index 38e4b192a..a391fac9a 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs @@ -876,7 +876,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs index 27c0ed88c..6678ba296 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs @@ -652,7 +652,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs index 3f1714a90..313ddbaea 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs @@ -734,7 +734,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs index ae19ea8db..cbd5aa1d0 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs @@ -732,7 +732,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/Subscription.cs b/src/Orb/Models/Subscriptions/Subscription.cs index 6fcd61393..c1b27d643 100644 --- a/src/Orb/Models/Subscriptions/Subscription.cs +++ b/src/Orb/Models/Subscriptions/Subscription.cs @@ -812,7 +812,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs index 080675a60..f67dca64f 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs @@ -175,13 +175,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs index 20b34bee4..d4291b423 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -788,12 +788,18 @@ IReadOnlyDictionary rawBodyData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - ["BodyData"] = this._rawBodyData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -1280,7 +1286,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3631,7 +3640,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5240,7 +5252,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6107,7 +6122,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6926,7 +6944,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7745,7 +7766,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -8504,7 +8528,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9300,7 +9327,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9994,7 +10024,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -12431,7 +12464,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -14126,7 +14162,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -15025,7 +15064,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -15863,7 +15905,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -16703,7 +16748,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -17485,7 +17533,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -18303,7 +18354,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs index 1677747e7..a9d1a9213 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs @@ -129,12 +129,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["SubscriptionID"] = this.SubscriptionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs index 8f7ea2acf..6033b3c64 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs @@ -66,12 +66,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["SubscriptionID"] = this.SubscriptionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs index ab5613970..c2cba5668 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs @@ -67,7 +67,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs index a5e13cd27..a85dd81bc 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs @@ -144,12 +144,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["SubscriptionID"] = this.SubscriptionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs index 7fdeb1659..8eb20b1f2 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs @@ -316,12 +316,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["SubscriptionID"] = this.SubscriptionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionListPage.cs b/src/Orb/Models/Subscriptions/SubscriptionListPage.cs index 27d1302eb..7ccdab2f4 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionListPage.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionListPage.cs @@ -63,7 +63,10 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); public override bool Equals(object? obj) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionListParams.cs b/src/Orb/Models/Subscriptions/SubscriptionListParams.cs index 66227c971..30ce4170b 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionListParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionListParams.cs @@ -208,11 +208,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index c367b59b6..34d9fdbdb 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -280,13 +280,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -800,7 +806,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1099,7 +1108,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -1652,7 +1664,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3698,7 +3713,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5368,7 +5386,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6186,7 +6207,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7004,7 +7028,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7761,7 +7788,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -8558,7 +8588,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9000,7 +9033,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9426,7 +9462,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9796,7 +9835,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -10254,7 +10296,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -10598,7 +10643,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -10967,7 +11015,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -11234,7 +11285,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs b/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs index 3668dedc7..a49285027 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs @@ -151,13 +151,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs index cb7893888..90ca7ecef 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -671,13 +671,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -1268,7 +1274,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -3806,7 +3815,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -5561,7 +5573,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -6509,7 +6524,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -7386,7 +7404,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -8263,7 +8284,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9079,7 +9103,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -9939,7 +9966,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -10704,7 +10734,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -13237,7 +13270,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -14997,7 +15033,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -15947,7 +15986,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -16824,7 +16866,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -17701,7 +17746,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -18523,7 +18571,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { @@ -19390,7 +19441,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs b/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs index 9ae659d8d..a0b01c36e 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs @@ -111,13 +111,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs index 6f3300f94..770e18ba0 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs @@ -71,12 +71,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["SubscriptionID"] = this.SubscriptionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs index d68122526..73088ae9e 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs @@ -98,13 +98,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs index f18b7278a..413cc10e3 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs @@ -68,12 +68,18 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["SubscriptionID"] = this.SubscriptionID, - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs index beb63d107..abb2d52a5 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs @@ -173,13 +173,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionUpdateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateParams.cs index d40b97811..6888dad85 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUpdateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUpdateParams.cs @@ -164,13 +164,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); diff --git a/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs index 4e847e367..351f9636f 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs @@ -137,13 +137,19 @@ 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(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), ModelBase.ToStringSerializerOptions ); @@ -385,7 +391,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/Subscriptions/SubscriptionUsage.cs b/src/Orb/Models/Subscriptions/SubscriptionUsage.cs index f9f3431bd..d33e5c671 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUsage.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUsage.cs @@ -200,7 +200,10 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); int VariantIndex() { diff --git a/src/Orb/Models/TopLevel/TopLevelPingParams.cs b/src/Orb/Models/TopLevel/TopLevelPingParams.cs index b4314ad11..4b6e37c44 100644 --- a/src/Orb/Models/TopLevel/TopLevelPingParams.cs +++ b/src/Orb/Models/TopLevel/TopLevelPingParams.cs @@ -65,11 +65,17 @@ IReadOnlyDictionary rawQueryData public override string ToString() => JsonSerializer.Serialize( - new Dictionary() - { - ["HeaderData"] = this._rawHeaderData.Freeze(), - ["QueryData"] = this._rawQueryData.Freeze(), - }, + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), ModelBase.ToStringSerializerOptions ); From 5c9d8d785b6c75e97c0d5f08227e42e10b5da3c8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 01:22:33 +0000 Subject: [PATCH 24/39] feat(api): api update --- .stats.yml | 4 +-- ...LedgerCreateEntryByExternalIDParamsTest.cs | 32 +++++++++++++++++++ .../Ledger/LedgerCreateEntryParamsTest.cs | 32 +++++++++++++++++++ .../Customers/Credits/LedgerServiceTest.cs | 2 ++ .../LedgerCreateEntryByExternalIDParams.cs | 22 +++++++++++++ .../Credits/Ledger/LedgerCreateEntryParams.cs | 22 +++++++++++++ 6 files changed, 112 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index c80eee48c..fba81f582 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c92fb451e13f157b3735f188acc8d57aa3adfbaac1683645e1ba4f432dd7a4f8.yml -openapi_spec_hash: dbcd87ecfbd3976eb3b99ec6f9fbc606 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-77e112caf7b2a2c7b0248b7245b5730bc72ab0ea84ba5d0777e7d0604ae04d26.yml +openapi_spec_hash: 966568dd08f34db64ba0ebace678268a config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs index 756454584..532a5bdac 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs @@ -38,6 +38,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -72,6 +73,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -113,6 +115,7 @@ public void Url_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -161,6 +164,7 @@ public void CopyConstructor_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -205,6 +209,7 @@ public void IncrementValidationWorks() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -304,6 +309,7 @@ public void IncrementSerializationRoundtripWorks() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -435,6 +441,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -465,6 +472,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -522,6 +530,7 @@ public void SerializationRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -566,6 +575,7 @@ public void FieldRoundtripThroughSerialization_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -604,6 +614,7 @@ public void FieldRoundtripThroughSerialization_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -661,6 +672,7 @@ public void Validation_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -784,6 +796,7 @@ public void CopyConstructor_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1042,6 +1055,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1053,6 +1067,7 @@ public void FieldRoundtrip_Works() LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsInvoiceDate expectedInvoiceDate = "2019-12-27"; string expectedItemID = "item_id"; + bool expectedMarkAsPaid = true; string expectedMemo = "memo"; long expectedNetTerms = 0; bool expectedRequireSuccessfulPayment = true; @@ -1061,6 +1076,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCustomDueDate, model.CustomDueDate); Assert.Equal(expectedInvoiceDate, model.InvoiceDate); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedMarkAsPaid, model.MarkAsPaid); Assert.Equal(expectedMemo, model.Memo); Assert.Equal(expectedNetTerms, model.NetTerms); Assert.Equal(expectedRequireSuccessfulPayment, model.RequireSuccessfulPayment); @@ -1075,6 +1091,7 @@ public void SerializationRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1099,6 +1116,7 @@ public void FieldRoundtripThroughSerialization_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1118,6 +1136,7 @@ public void FieldRoundtripThroughSerialization_Works() LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsInvoiceDate expectedInvoiceDate = "2019-12-27"; string expectedItemID = "item_id"; + bool expectedMarkAsPaid = true; string expectedMemo = "memo"; long expectedNetTerms = 0; bool expectedRequireSuccessfulPayment = true; @@ -1126,6 +1145,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCustomDueDate, deserialized.CustomDueDate); Assert.Equal(expectedInvoiceDate, deserialized.InvoiceDate); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedMarkAsPaid, deserialized.MarkAsPaid); Assert.Equal(expectedMemo, deserialized.Memo); Assert.Equal(expectedNetTerms, deserialized.NetTerms); Assert.Equal(expectedRequireSuccessfulPayment, deserialized.RequireSuccessfulPayment); @@ -1140,6 +1160,7 @@ public void Validation_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1161,6 +1182,8 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() NetTerms = 0, }; + Assert.Null(model.MarkAsPaid); + Assert.False(model.RawData.ContainsKey("mark_as_paid")); Assert.Null(model.RequireSuccessfulPayment); Assert.False(model.RawData.ContainsKey("require_successful_payment")); } @@ -1194,9 +1217,12 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() NetTerms = 0, // Null should be interpreted as omitted for these properties + MarkAsPaid = null, RequireSuccessfulPayment = null, }; + Assert.Null(model.MarkAsPaid); + Assert.False(model.RawData.ContainsKey("mark_as_paid")); Assert.Null(model.RequireSuccessfulPayment); Assert.False(model.RawData.ContainsKey("require_successful_payment")); } @@ -1214,6 +1240,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() NetTerms = 0, // Null should be interpreted as omitted for these properties + MarkAsPaid = null, RequireSuccessfulPayment = null, }; @@ -1226,6 +1253,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1247,6 +1275,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1259,6 +1288,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1286,6 +1316,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1307,6 +1338,7 @@ public void CopyConstructor_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs index 37290cb1a..0c2b1cab4 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs @@ -37,6 +37,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -69,6 +70,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -109,6 +111,7 @@ public void Url_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -154,6 +157,7 @@ public void CopyConstructor_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -196,6 +200,7 @@ public void IncrementValidationWorks() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -289,6 +294,7 @@ public void IncrementSerializationRoundtripWorks() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -415,6 +421,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -444,6 +451,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -500,6 +508,7 @@ public void SerializationRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -542,6 +551,7 @@ public void FieldRoundtripThroughSerialization_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -578,6 +588,7 @@ public void FieldRoundtripThroughSerialization_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -634,6 +645,7 @@ public void Validation_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -756,6 +768,7 @@ public void CopyConstructor_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -998,6 +1011,7 @@ public void FieldRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1007,6 +1021,7 @@ public void FieldRoundtrip_Works() Ledger::CustomDueDate expectedCustomDueDate = "2019-12-27"; Ledger::InvoiceDate expectedInvoiceDate = "2019-12-27"; string expectedItemID = "item_id"; + bool expectedMarkAsPaid = true; string expectedMemo = "memo"; long expectedNetTerms = 0; bool expectedRequireSuccessfulPayment = true; @@ -1015,6 +1030,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCustomDueDate, model.CustomDueDate); Assert.Equal(expectedInvoiceDate, model.InvoiceDate); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedMarkAsPaid, model.MarkAsPaid); Assert.Equal(expectedMemo, model.Memo); Assert.Equal(expectedNetTerms, model.NetTerms); Assert.Equal(expectedRequireSuccessfulPayment, model.RequireSuccessfulPayment); @@ -1029,6 +1045,7 @@ public void SerializationRoundtrip_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1052,6 +1069,7 @@ public void FieldRoundtripThroughSerialization_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1068,6 +1086,7 @@ public void FieldRoundtripThroughSerialization_Works() Ledger::CustomDueDate expectedCustomDueDate = "2019-12-27"; Ledger::InvoiceDate expectedInvoiceDate = "2019-12-27"; string expectedItemID = "item_id"; + bool expectedMarkAsPaid = true; string expectedMemo = "memo"; long expectedNetTerms = 0; bool expectedRequireSuccessfulPayment = true; @@ -1076,6 +1095,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCustomDueDate, deserialized.CustomDueDate); Assert.Equal(expectedInvoiceDate, deserialized.InvoiceDate); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedMarkAsPaid, deserialized.MarkAsPaid); Assert.Equal(expectedMemo, deserialized.Memo); Assert.Equal(expectedNetTerms, deserialized.NetTerms); Assert.Equal(expectedRequireSuccessfulPayment, deserialized.RequireSuccessfulPayment); @@ -1090,6 +1110,7 @@ public void Validation_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -1111,6 +1132,8 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() NetTerms = 0, }; + Assert.Null(model.MarkAsPaid); + Assert.False(model.RawData.ContainsKey("mark_as_paid")); Assert.Null(model.RequireSuccessfulPayment); Assert.False(model.RawData.ContainsKey("require_successful_payment")); } @@ -1144,9 +1167,12 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() NetTerms = 0, // Null should be interpreted as omitted for these properties + MarkAsPaid = null, RequireSuccessfulPayment = null, }; + Assert.Null(model.MarkAsPaid); + Assert.False(model.RawData.ContainsKey("mark_as_paid")); Assert.Null(model.RequireSuccessfulPayment); Assert.False(model.RawData.ContainsKey("require_successful_payment")); } @@ -1164,6 +1190,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() NetTerms = 0, // Null should be interpreted as omitted for these properties + MarkAsPaid = null, RequireSuccessfulPayment = null, }; @@ -1176,6 +1203,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1197,6 +1225,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1209,6 +1238,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1236,6 +1266,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1257,6 +1288,7 @@ public void CopyConstructor_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, diff --git a/src/Orb.Tests/Services/Customers/Credits/LedgerServiceTest.cs b/src/Orb.Tests/Services/Customers/Credits/LedgerServiceTest.cs index 9107a7baf..ab1002963 100644 --- a/src/Orb.Tests/Services/Customers/Credits/LedgerServiceTest.cs +++ b/src/Orb.Tests/Services/Customers/Credits/LedgerServiceTest.cs @@ -47,6 +47,7 @@ public async Task CreateEntry_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, @@ -91,6 +92,7 @@ public async Task CreateEntryByExternalID_Works() CustomDueDate = "2019-12-27", InvoiceDate = "2019-12-27", ItemID = "item_id", + MarkAsPaid = true, Memo = "memo", NetTerms = 0, RequireSuccessfulPayment = true, diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index 1d8c1a5f2..c7d9f09d2 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -1376,6 +1376,27 @@ public string? ItemID init { this._rawData.Set("item_id", value); } } + /// + /// If true, the new credits purchase invoice will be marked as paid. + /// + public bool? MarkAsPaid + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("mark_as_paid"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("mark_as_paid", value); + } + } + /// /// An optional memo to display on the invoice. /// @@ -1436,6 +1457,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index 36367c591..246f9540c 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -1235,6 +1235,27 @@ public string? ItemID init { this._rawData.Set("item_id", value); } } + /// + /// If true, the new credits purchase invoice will be marked as paid. + /// + public bool? MarkAsPaid + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("mark_as_paid"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("mark_as_paid", value); + } + } + /// /// An optional memo to display on the invoice. /// @@ -1295,6 +1316,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; From ebe83bc63b23dd2c2f4b86005d8c50d579c5fd86 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 01:22:40 +0000 Subject: [PATCH 25/39] feat(api): api update --- .stats.yml | 4 +- .../Models/Metrics/BillableMetricTest.cs | 217 ++++++ .../Metrics/MetricListPageResponseTest.cs | 49 ++ src/Orb.Tests/Models/PriceIntervalTest.cs | 633 +++++++++++++++++- .../Prices/PriceEvaluateMultipleParamsTest.cs | 91 +++ .../Models/Prices/PriceEvaluateParamsTest.cs | 39 ++ .../PriceEvaluatePreviewEventsParamsTest.cs | 91 +++ .../MutatedSubscriptionTest.cs | 44 ++ .../SubscriptionChangeApplyResponseTest.cs | 44 ++ .../SubscriptionChangeCancelResponseTest.cs | 44 ++ .../SubscriptionChangeRetrieveResponseTest.cs | 44 ++ .../SubscriptionCreateParamsTest.cs | 150 +++++ .../SubscriptionPriceIntervalsParamsTest.cs | 166 +++++ ...ubscriptionSchedulePlanChangeParamsTest.cs | 134 ++++ .../SubscriptionSubscriptionsTest.cs | 28 + .../Models/Subscriptions/SubscriptionTest.cs | 28 + src/Orb/Models/Metrics/BillableMetric.cs | 28 + src/Orb/Models/PriceInterval.cs | 23 + .../Prices/PriceEvaluateMultipleParams.cs | 23 + src/Orb/Models/Prices/PriceEvaluateParams.cs | 22 + .../PriceEvaluatePreviewEventsParams.cs | 23 + .../Subscriptions/SubscriptionCreateParams.cs | 46 ++ .../SubscriptionPriceIntervalsParams.cs | 46 ++ .../SubscriptionSchedulePlanChangeParams.cs | 46 ++ 24 files changed, 2060 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index fba81f582..2fd311799 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-77e112caf7b2a2c7b0248b7245b5730bc72ab0ea84ba5d0777e7d0604ae04d26.yml -openapi_spec_hash: 966568dd08f34db64ba0ebace678268a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-3c7ee3ec9931aaeeb5e015a598812cde9edc09f114adb8759ef4c2054c90f7dc.yml +openapi_spec_hash: a14720041156fe4f353449142edacf0d config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/src/Orb.Tests/Models/Metrics/BillableMetricTest.cs b/src/Orb.Tests/Models/Metrics/BillableMetricTest.cs index 8cd407cf1..138bc8a41 100644 --- a/src/Orb.Tests/Models/Metrics/BillableMetricTest.cs +++ b/src/Orb.Tests/Models/Metrics/BillableMetricTest.cs @@ -37,6 +37,13 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }; string expectedID = "id"; @@ -60,6 +67,13 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedName = "name"; ApiEnum expectedStatus = Status.Active; + List> expectedParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ]; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedDescription, model.Description); @@ -73,6 +87,21 @@ public void FieldRoundtrip_Works() } Assert.Equal(expectedName, model.Name); Assert.Equal(expectedStatus, model.Status); + Assert.NotNull(model.ParameterDefinitions); + Assert.Equal(expectedParameterDefinitions.Count, model.ParameterDefinitions.Count); + for (int i = 0; i < expectedParameterDefinitions.Count; i++) + { + Assert.Equal( + expectedParameterDefinitions[i].Count, + model.ParameterDefinitions[i].Count + ); + foreach (var item in expectedParameterDefinitions[i]) + { + Assert.True(model.ParameterDefinitions[i].TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.ParameterDefinitions[i][item.Key])); + } + } } [Fact] @@ -102,6 +131,13 @@ public void SerializationRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -140,6 +176,13 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -170,6 +213,13 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedName = "name"; ApiEnum expectedStatus = Status.Active; + List> expectedParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ]; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedDescription, deserialized.Description); @@ -183,6 +233,25 @@ public void FieldRoundtripThroughSerialization_Works() } Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedStatus, deserialized.Status); + Assert.NotNull(deserialized.ParameterDefinitions); + Assert.Equal(expectedParameterDefinitions.Count, deserialized.ParameterDefinitions.Count); + for (int i = 0; i < expectedParameterDefinitions.Count; i++) + { + Assert.Equal( + expectedParameterDefinitions[i].Count, + deserialized.ParameterDefinitions[i].Count + ); + foreach (var item in expectedParameterDefinitions[i]) + { + Assert.True( + deserialized.ParameterDefinitions[i].TryGetValue(item.Key, out var value) + ); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.ParameterDefinitions[i][item.Key]) + ); + } + } } [Fact] @@ -212,6 +281,147 @@ public void Validation_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BillableMetric + { + ID = "id", + Description = "description", + Item = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalConnections = + [ + new() + { + ExternalConnectionName = + ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + Status = Status.Active, + }; + + Assert.Null(model.ParameterDefinitions); + Assert.False(model.RawData.ContainsKey("parameter_definitions")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BillableMetric + { + ID = "id", + Description = "description", + Item = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalConnections = + [ + new() + { + ExternalConnectionName = + ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + Status = Status.Active, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BillableMetric + { + ID = "id", + Description = "description", + Item = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalConnections = + [ + new() + { + ExternalConnectionName = + ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + Status = Status.Active, + + ParameterDefinitions = null, + }; + + Assert.Null(model.ParameterDefinitions); + Assert.True(model.RawData.ContainsKey("parameter_definitions")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new BillableMetric + { + ID = "id", + Description = "description", + Item = new() + { + ID = "id", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalConnections = + [ + new() + { + ExternalConnectionName = + ItemExternalConnectionExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + Status = Status.Active, + + ParameterDefinitions = null, }; model.Validate(); @@ -244,6 +454,13 @@ public void CopyConstructor_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }; BillableMetric copied = new(model); diff --git a/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs b/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs index 3cbb9c4e5..5b71a0956 100644 --- a/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs @@ -41,6 +41,13 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -72,6 +79,13 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }, ]; Models::PaginationMetadata expectedPaginationMetadata = new() @@ -119,6 +133,13 @@ public void SerializationRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -164,6 +185,13 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -202,6 +230,13 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }, ]; Models::PaginationMetadata expectedPaginationMetadata = new() @@ -249,6 +284,13 @@ public void Validation_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -288,6 +330,13 @@ public void CopyConstructor_Works() Metadata = new Dictionary() { { "foo", "string" } }, Name = "name", Status = Status.Active, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, diff --git a/src/Orb.Tests/Models/PriceIntervalTest.cs b/src/Orb.Tests/Models/PriceIntervalTest.cs index dc848edd7..575eeb629 100644 --- a/src/Orb.Tests/Models/PriceIntervalTest.cs +++ b/src/Orb.Tests/Models/PriceIntervalTest.cs @@ -147,6 +147,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; string expectedID = "id"; @@ -283,6 +287,10 @@ public void FieldRoundtrip_Works() }; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); List expectedUsageCustomerIds = ["string"]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillingCycleDay, model.BillingCycleDay); @@ -311,6 +319,14 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedUsageCustomerIds[i], model.UsageCustomerIds[i]); } + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } } [Fact] @@ -452,6 +468,10 @@ public void SerializationRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -602,6 +622,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -745,6 +769,10 @@ public void FieldRoundtripThroughSerialization_Works() }; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); List expectedUsageCustomerIds = ["string"]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillingCycleDay, deserialized.BillingCycleDay); @@ -776,6 +804,19 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedUsageCustomerIds[i], deserialized.UsageCustomerIds[i]); } + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } } [Fact] @@ -917,13 +958,162 @@ public void Validation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; model.Validate(); } [Fact] - public void CopyConstructor_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceInterval + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }; + + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() { var model = new PriceInterval { @@ -1063,6 +1253,447 @@ public void CopyConstructor_Works() UsageCustomerIds = ["string"], }; + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceInterval + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + + MetricParameterOverrides = null, + }; + + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PriceInterval + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + + MetricParameterOverrides = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceInterval + { + ID = "id", + BillingCycleDay = 0, + CanDeferBilling = true, + CurrentBillingPeriodEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CurrentBillingPeriodStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "filter", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PriceID = "price_id", + Quantity = 0, + }, + ], + Price = new Unit() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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 = UnitPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + }; + PriceInterval copied = new(model); Assert.Equal(model, copied); diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs index 56e11020a..15d9598cb 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs @@ -26,6 +26,10 @@ public void FieldRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -81,6 +85,10 @@ public void FieldRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -183,6 +191,10 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -247,6 +259,10 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -330,6 +346,10 @@ public void CopyConstructor_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -390,6 +410,10 @@ public void FieldRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -438,6 +462,10 @@ public void FieldRoundtrip_Works() [ "case when my_event_type = 'foo' then true else false end", ]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Price expectedPrice = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -486,6 +514,14 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedGroupingKeys[i], model.GroupingKeys[i]); } + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } Assert.Equal(expectedPrice, model.Price); Assert.Equal(expectedPriceID, model.PriceID); } @@ -498,6 +534,10 @@ public void SerializationRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -557,6 +597,10 @@ public void FieldRoundtripThroughSerialization_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -612,6 +656,10 @@ public void FieldRoundtripThroughSerialization_Works() [ "case when my_event_type = 'foo' then true else false end", ]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Price expectedPrice = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -660,6 +708,19 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedGroupingKeys[i], deserialized.GroupingKeys[i]); } + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } Assert.Equal(expectedPrice, deserialized.Price); Assert.Equal(expectedPriceID, deserialized.PriceID); } @@ -672,6 +733,10 @@ public void Validation_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -724,6 +789,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { ExternalPriceID = "external_price_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -777,6 +846,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() { ExternalPriceID = "external_price_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -829,6 +902,10 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { ExternalPriceID = "external_price_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -885,6 +962,10 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() { ExternalPriceID = "external_price_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, @@ -945,6 +1026,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.Filter); Assert.False(model.RawData.ContainsKey("filter")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.Price); Assert.False(model.RawData.ContainsKey("price")); Assert.Null(model.PriceID); @@ -971,6 +1054,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; @@ -979,6 +1063,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.Filter); Assert.True(model.RawData.ContainsKey("filter")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.Price); Assert.True(model.RawData.ContainsKey("price")); Assert.Null(model.PriceID); @@ -994,6 +1080,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; @@ -1009,6 +1096,10 @@ public void CopyConstructor_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new Models::NewFloatingUnitPrice() { Cadence = Models::NewFloatingUnitPriceCadence.Annual, diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs index c3660fc07..640afde62 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text.Json; using Orb.Models.Prices; namespace Orb.Tests.Models.Prices; @@ -18,6 +19,10 @@ public void FieldRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; string expectedPriceID = "price_id"; @@ -30,6 +35,10 @@ public void FieldRoundtrip_Works() [ "case when my_event_type = 'foo' then true else false end", ]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Assert.Equal(expectedPriceID, parameters.PriceID); Assert.Equal(expectedTimeframeEnd, parameters.TimeframeEnd); @@ -43,6 +52,19 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedGroupingKeys[i], parameters.GroupingKeys[i]); } + Assert.NotNull(parameters.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + parameters.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(parameters.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, parameters.MetricParameterOverrides[item.Key]) + ); + } } [Fact] @@ -56,6 +78,10 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() CustomerID = "customer_id", ExternalCustomerID = "external_customer_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; Assert.Null(parameters.GroupingKeys); @@ -73,6 +99,10 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() CustomerID = "customer_id", ExternalCustomerID = "external_customer_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, // Null should be interpreted as omitted for these properties GroupingKeys = null, @@ -99,6 +129,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Assert.False(parameters.RawBodyData.ContainsKey("external_customer_id")); Assert.Null(parameters.Filter); Assert.False(parameters.RawBodyData.ContainsKey("filter")); + Assert.Null(parameters.MetricParameterOverrides); + Assert.False(parameters.RawBodyData.ContainsKey("metric_parameter_overrides")); } [Fact] @@ -114,6 +146,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() CustomerID = null, ExternalCustomerID = null, Filter = null, + MetricParameterOverrides = null, }; Assert.Null(parameters.CustomerID); @@ -122,6 +155,8 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Assert.True(parameters.RawBodyData.ContainsKey("external_customer_id")); Assert.Null(parameters.Filter); Assert.True(parameters.RawBodyData.ContainsKey("filter")); + Assert.Null(parameters.MetricParameterOverrides); + Assert.True(parameters.RawBodyData.ContainsKey("metric_parameter_overrides")); } [Fact] @@ -151,6 +186,10 @@ public void CopyConstructor_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; PriceEvaluateParams copied = new(parameters); diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs index d1beeaa6e..7f313247f 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs @@ -40,6 +40,10 @@ public void FieldRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -109,6 +113,10 @@ public void FieldRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -235,6 +243,10 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -313,6 +325,10 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -410,6 +426,10 @@ public void CopyConstructor_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -686,6 +706,10 @@ public void FieldRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -733,6 +757,10 @@ public void FieldRoundtrip_Works() [ "case when my_event_type = 'foo' then true else false end", ]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; PriceEvaluatePreviewEventsParamsPriceEvaluationPrice expectedPrice = new NewFloatingUnitPrice() { @@ -782,6 +810,14 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedGroupingKeys[i], model.GroupingKeys[i]); } + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } Assert.Equal(expectedPrice, model.Price); Assert.Equal(expectedPriceID, model.PriceID); } @@ -794,6 +830,10 @@ public void SerializationRoundtrip_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -853,6 +893,10 @@ public void FieldRoundtripThroughSerialization_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -908,6 +952,10 @@ public void FieldRoundtripThroughSerialization_Works() [ "case when my_event_type = 'foo' then true else false end", ]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; PriceEvaluatePreviewEventsParamsPriceEvaluationPrice expectedPrice = new NewFloatingUnitPrice() { @@ -957,6 +1005,19 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedGroupingKeys[i], deserialized.GroupingKeys[i]); } + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } Assert.Equal(expectedPrice, deserialized.Price); Assert.Equal(expectedPriceID, deserialized.PriceID); } @@ -969,6 +1030,10 @@ public void Validation_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -1020,6 +1085,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { ExternalPriceID = "external_price_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -1072,6 +1141,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() { ExternalPriceID = "external_price_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -1123,6 +1196,10 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { ExternalPriceID = "external_price_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -1178,6 +1255,10 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() { ExternalPriceID = "external_price_id", Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, @@ -1237,6 +1318,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.Filter); Assert.False(model.RawData.ContainsKey("filter")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.Price); Assert.False(model.RawData.ContainsKey("price")); Assert.Null(model.PriceID); @@ -1263,6 +1346,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; @@ -1271,6 +1355,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.Filter); Assert.True(model.RawData.ContainsKey("filter")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.Price); Assert.True(model.RawData.ContainsKey("price")); Assert.Null(model.PriceID); @@ -1286,6 +1372,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; @@ -1301,6 +1388,10 @@ public void CopyConstructor_Works() 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, Price = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, diff --git a/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs index 4a5abb364..98a19e334 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs @@ -639,6 +639,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2166,6 +2170,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ]; Models::CouponRedemption expectedRedeemedCoupon = new() @@ -3720,6 +3728,10 @@ public void SerializationRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -5259,6 +5271,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -6793,6 +6809,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ]; Models::CouponRedemption expectedRedeemedCoupon = new() @@ -8356,6 +8376,10 @@ public void Validation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -9889,6 +9913,10 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10533,6 +10561,10 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11176,6 +11208,10 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11822,6 +11858,10 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -12467,6 +12507,10 @@ public void CopyConstructor_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs index 34d57bdd9..7dafea919 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs @@ -655,6 +655,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2228,6 +2232,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3793,6 +3801,10 @@ public void SerializationRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -5389,6 +5401,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -6969,6 +6985,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -8534,6 +8554,10 @@ public void Validation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10124,6 +10148,10 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11719,6 +11747,10 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -13303,6 +13335,10 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -14905,6 +14941,10 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -16496,6 +16536,10 @@ public void CopyConstructor_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs index 8a30a78ff..36285cc65 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs @@ -655,6 +655,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2228,6 +2232,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3793,6 +3801,10 @@ public void SerializationRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -5389,6 +5401,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -6969,6 +6985,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -8534,6 +8554,10 @@ public void Validation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10124,6 +10148,10 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11719,6 +11747,10 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -13303,6 +13335,10 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -14905,6 +14941,10 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -16496,6 +16536,10 @@ public void CopyConstructor_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs index 0b239667d..0ad1501cd 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs @@ -655,6 +655,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2228,6 +2232,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3793,6 +3801,10 @@ public void SerializationRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -5389,6 +5401,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -6969,6 +6985,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -8534,6 +8554,10 @@ public void Validation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10124,6 +10148,10 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11719,6 +11747,10 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -13303,6 +13335,10 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -14905,6 +14941,10 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -16496,6 +16536,10 @@ public void CopyConstructor_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs index ab5b0dfa7..e4f1c1683 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs @@ -85,6 +85,10 @@ public void FieldRoundtrip_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -234,6 +238,10 @@ public void FieldRoundtrip_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -353,6 +361,10 @@ public void FieldRoundtrip_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -502,6 +514,10 @@ public void FieldRoundtrip_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -717,6 +733,10 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -865,6 +885,10 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -995,6 +1019,10 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -1143,6 +1171,10 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -1467,6 +1499,10 @@ public void CopyConstructor_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -1616,6 +1652,10 @@ public void CopyConstructor_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -2385,6 +2425,10 @@ public void FieldRoundtrip_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -2467,6 +2511,10 @@ public void FieldRoundtrip_Works() DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedExternalPriceID = "external_price_id"; string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedMinimumAmount = "1.23"; long expectedPlanPhaseOrder = 0; Subscriptions::Price expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() @@ -2521,6 +2569,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedEndDate, model.EndDate); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } Assert.Equal(expectedMinimumAmount, model.MinimumAmount); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPrice, model.Price); @@ -2570,6 +2626,10 @@ public void SerializationRoundtrip_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -2666,6 +2726,10 @@ public void FieldRoundtripThroughSerialization_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -2755,6 +2819,10 @@ public void FieldRoundtripThroughSerialization_Works() DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedExternalPriceID = "external_price_id"; string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedMinimumAmount = "1.23"; long expectedPlanPhaseOrder = 0; Subscriptions::Price expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() @@ -2809,6 +2877,19 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedEndDate, deserialized.EndDate); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPrice, deserialized.Price); @@ -2858,6 +2939,10 @@ public void Validation_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -2921,6 +3006,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.MaximumAmount); Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.False(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.PlanPhaseOrder); @@ -2951,6 +3038,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() EndDate = null, ExternalPriceID = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, PlanPhaseOrder = null, Price = null, @@ -2968,6 +3056,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.MaximumAmount); Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.True(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.PlanPhaseOrder); @@ -2990,6 +3080,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() EndDate = null, ExternalPriceID = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, PlanPhaseOrder = null, Price = null, @@ -3042,6 +3133,10 @@ public void CopyConstructor_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -12562,6 +12657,10 @@ public void FieldRoundtrip_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -12643,6 +12742,10 @@ public void FieldRoundtrip_Works() string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 2; string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedMinimumAmount = "1.23"; Subscriptions::ReplacePricePrice expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() @@ -12697,6 +12800,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } Assert.Equal(expectedMinimumAmount, model.MinimumAmount); Assert.Equal(expectedPrice, model.Price); Assert.Equal(expectedPriceID, model.PriceID); @@ -12745,6 +12856,10 @@ public void SerializationRoundtrip_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -12840,6 +12955,10 @@ public void FieldRoundtripThroughSerialization_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -12928,6 +13047,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 2; string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedMinimumAmount = "1.23"; Subscriptions::ReplacePricePrice expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() @@ -12982,6 +13105,19 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); Assert.Equal(expectedPrice, deserialized.Price); Assert.Equal(expectedPriceID, deserialized.PriceID); @@ -13030,6 +13166,10 @@ public void Validation_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -13091,6 +13231,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); Assert.Null(model.MaximumAmount); Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.False(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.Price); @@ -13119,6 +13261,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExternalPriceID = null, FixedPriceQuantity = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -13134,6 +13277,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); Assert.Null(model.MaximumAmount); Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.True(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.Price); @@ -13154,6 +13299,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExternalPriceID = null, FixedPriceQuantity = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -13205,6 +13351,10 @@ public void CopyConstructor_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs index ab1bc7c36..ab5170bce 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs @@ -59,6 +59,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -151,6 +155,10 @@ public void FieldRoundtrip_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }, @@ -210,6 +218,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -301,6 +313,10 @@ public void FieldRoundtrip_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }, @@ -439,6 +455,10 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -529,6 +549,10 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }, @@ -599,6 +623,10 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -689,6 +717,10 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }, @@ -778,6 +810,10 @@ public void CopyConstructor_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -870,6 +906,10 @@ public void CopyConstructor_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }, @@ -937,6 +977,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1021,6 +1065,10 @@ public void FieldRoundtrip_Works() }, ]; double expectedMaximumAmount = 0; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; double expectedMinimumAmount = 0; Subscriptions::PriceModel expectedPrice = new NewFloatingUnitPrice() { @@ -1088,6 +1136,14 @@ public void FieldRoundtrip_Works() ); } Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } Assert.Equal(expectedMinimumAmount, model.MinimumAmount); Assert.Equal(expectedPrice, model.Price); Assert.Equal(expectedPriceID, model.PriceID); @@ -1143,6 +1199,10 @@ public void SerializationRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1239,6 +1299,10 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1330,6 +1394,10 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; double expectedMaximumAmount = 0; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; double expectedMinimumAmount = 0; Subscriptions::PriceModel expectedPrice = new NewFloatingUnitPrice() { @@ -1397,6 +1465,19 @@ public void FieldRoundtripThroughSerialization_Works() ); } Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); Assert.Equal(expectedPrice, deserialized.Price); Assert.Equal(expectedPriceID, deserialized.PriceID); @@ -1452,6 +1533,10 @@ public void Validation_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1522,6 +1607,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("fixed_fee_quantity_transitions")); Assert.Null(model.MaximumAmount); Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.False(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.Price); @@ -1558,6 +1645,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Filter = null, FixedFeeQuantityTransitions = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -1580,6 +1668,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("fixed_fee_quantity_transitions")); Assert.Null(model.MaximumAmount); Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.True(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.Price); @@ -1605,6 +1695,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Filter = null, FixedFeeQuantityTransitions = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -1658,6 +1749,10 @@ public void CopyConstructor_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -10572,6 +10667,10 @@ public void FieldRoundtrip_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }; @@ -10591,6 +10690,10 @@ public void FieldRoundtrip_Works() Quantity = 5, }, ]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Subscriptions::EditStartDate expectedStartDate = DateTimeOffset.Parse( "2019-12-27T18:11:19.117Z" ); @@ -10613,6 +10716,14 @@ public void FieldRoundtrip_Works() model.FixedFeeQuantityTransitions[i] ); } + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } Assert.Equal(expectedStartDate, model.StartDate); Assert.NotNull(model.UsageCustomerIds); Assert.Equal(expectedUsageCustomerIds.Count, model.UsageCustomerIds.Count); @@ -10640,6 +10751,10 @@ public void SerializationRoundtrip_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }; @@ -10671,6 +10786,10 @@ public void FieldRoundtripThroughSerialization_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }; @@ -10697,6 +10816,10 @@ public void FieldRoundtripThroughSerialization_Works() Quantity = 5, }, ]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Subscriptions::EditStartDate expectedStartDate = DateTimeOffset.Parse( "2019-12-27T18:11:19.117Z" ); @@ -10719,6 +10842,19 @@ public void FieldRoundtripThroughSerialization_Works() deserialized.FixedFeeQuantityTransitions[i] ); } + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } Assert.Equal(expectedStartDate, deserialized.StartDate); Assert.NotNull(deserialized.UsageCustomerIds); Assert.Equal(expectedUsageCustomerIds.Count, deserialized.UsageCustomerIds.Count); @@ -10746,6 +10882,10 @@ public void Validation_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }; @@ -10771,6 +10911,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], }; @@ -10796,6 +10940,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], }; @@ -10820,6 +10968,10 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], // Null should be interpreted as omitted for these properties @@ -10848,6 +11000,10 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], // Null should be interpreted as omitted for these properties @@ -10876,6 +11032,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("filter")); Assert.Null(model.FixedFeeQuantityTransitions); Assert.False(model.RawData.ContainsKey("fixed_fee_quantity_transitions")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.UsageCustomerIds); Assert.False(model.RawData.ContainsKey("usage_customer_ids")); } @@ -10905,6 +11063,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() EndDate = null, Filter = null, FixedFeeQuantityTransitions = null, + MetricParameterOverrides = null, UsageCustomerIds = null, }; @@ -10918,6 +11077,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("filter")); Assert.Null(model.FixedFeeQuantityTransitions); Assert.True(model.RawData.ContainsKey("fixed_fee_quantity_transitions")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.UsageCustomerIds); Assert.True(model.RawData.ContainsKey("usage_customer_ids")); } @@ -10935,6 +11096,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() EndDate = null, Filter = null, FixedFeeQuantityTransitions = null, + MetricParameterOverrides = null, UsageCustomerIds = null, }; @@ -10959,6 +11121,10 @@ public void CopyConstructor_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], }; diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs index 839aed0fd..dbdd1bd90 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs @@ -88,6 +88,10 @@ public void FieldRoundtrip_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -230,6 +234,10 @@ public void FieldRoundtrip_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -354,6 +362,10 @@ public void FieldRoundtrip_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -499,6 +511,10 @@ public void FieldRoundtrip_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -870,6 +886,10 @@ public void CopyConstructor_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -1012,6 +1032,10 @@ public void CopyConstructor_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -1865,6 +1889,10 @@ public void FieldRoundtrip_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -1947,6 +1975,10 @@ public void FieldRoundtrip_Works() DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedExternalPriceID = "external_price_id"; string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedMinimumAmount = "1.23"; long expectedPlanPhaseOrder = 0; Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = @@ -2002,6 +2034,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedEndDate, model.EndDate); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } Assert.Equal(expectedMinimumAmount, model.MinimumAmount); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPrice, model.Price); @@ -2051,6 +2091,10 @@ public void SerializationRoundtrip_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -2148,6 +2192,10 @@ public void FieldRoundtripThroughSerialization_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -2238,6 +2286,10 @@ public void FieldRoundtripThroughSerialization_Works() DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedExternalPriceID = "external_price_id"; string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedMinimumAmount = "1.23"; long expectedPlanPhaseOrder = 0; Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = @@ -2293,6 +2345,19 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedEndDate, deserialized.EndDate); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPrice, deserialized.Price); @@ -2342,6 +2407,10 @@ public void Validation_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -2405,6 +2474,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.MaximumAmount); Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.False(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.PlanPhaseOrder); @@ -2435,6 +2506,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() EndDate = null, ExternalPriceID = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, PlanPhaseOrder = null, Price = null, @@ -2452,6 +2524,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.MaximumAmount); Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.True(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.PlanPhaseOrder); @@ -2474,6 +2548,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() EndDate = null, ExternalPriceID = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, PlanPhaseOrder = null, Price = null, @@ -2526,6 +2601,10 @@ public void CopyConstructor_Works() EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", PlanPhaseOrder = 0, Price = new Subscriptions::NewSubscriptionUnitPrice() @@ -12777,6 +12856,10 @@ public void FieldRoundtrip_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -12858,6 +12941,10 @@ public void FieldRoundtrip_Works() string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 2; string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedMinimumAmount = "1.23"; Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() @@ -12912,6 +12999,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } Assert.Equal(expectedMinimumAmount, model.MinimumAmount); Assert.Equal(expectedPrice, model.Price); Assert.Equal(expectedPriceID, model.PriceID); @@ -12960,6 +13055,10 @@ public void SerializationRoundtrip_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -13056,6 +13155,10 @@ public void FieldRoundtripThroughSerialization_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -13145,6 +13248,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 2; string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; string expectedMinimumAmount = "1.23"; Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() @@ -13199,6 +13306,19 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); Assert.Equal(expectedPrice, deserialized.Price); Assert.Equal(expectedPriceID, deserialized.PriceID); @@ -13247,6 +13367,10 @@ public void Validation_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { @@ -13311,6 +13435,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); Assert.Null(model.MaximumAmount); Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.False(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.Price); @@ -13342,6 +13468,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExternalPriceID = null, FixedPriceQuantity = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -13357,6 +13484,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); Assert.Null(model.MaximumAmount); Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); Assert.Null(model.MinimumAmount); Assert.True(model.RawData.ContainsKey("minimum_amount")); Assert.Null(model.Price); @@ -13377,6 +13506,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExternalPriceID = null, FixedPriceQuantity = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -13428,6 +13558,10 @@ public void CopyConstructor_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 2, MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = "1.23", Price = new Subscriptions::NewSubscriptionUnitPrice() { diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs index bae4dda00..ecbc9e207 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs @@ -659,6 +659,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -1310,6 +1314,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -1985,6 +1993,10 @@ public void SerializationRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2658,6 +2670,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3316,6 +3332,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3991,6 +4011,10 @@ public void Validation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -4658,6 +4682,10 @@ public void CopyConstructor_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs index 4dbc74e11..84a564135 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs @@ -641,6 +641,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -1272,6 +1276,10 @@ public void FieldRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ]; CouponRedemption expectedRedeemedCoupon = new() @@ -1977,6 +1985,10 @@ public void SerializationRoundtrip_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2628,6 +2640,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3266,6 +3282,10 @@ public void FieldRoundtripThroughSerialization_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ]; CouponRedemption expectedRedeemedCoupon = new() @@ -3980,6 +4000,10 @@ public void Validation_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -4625,6 +4649,10 @@ public void CopyConstructor_Works() }, StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), UsageCustomerIds = ["string"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() diff --git a/src/Orb/Models/Metrics/BillableMetric.cs b/src/Orb/Models/Metrics/BillableMetric.cs index 488676987..d50aefda7 100644 --- a/src/Orb/Models/Metrics/BillableMetric.cs +++ b/src/Orb/Models/Metrics/BillableMetric.cs @@ -1,6 +1,8 @@ using System.Collections.Frozen; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; using Orb.Core; @@ -95,6 +97,31 @@ public required ApiEnum Status init { this._rawData.Set("status", value); } } + public IReadOnlyList>? ParameterDefinitions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray> + >("parameter_definitions"); + } + init + { + this._rawData.Set>?>( + "parameter_definitions", + value == null + ? null + : ImmutableArray.ToImmutableArray( + Enumerable.Select( + value, + (item) => FrozenDictionary.ToFrozenDictionary(item) + ) + ) + ); + } + } + /// public override void Validate() { @@ -104,6 +131,7 @@ public override void Validate() _ = this.Metadata; _ = this.Name; this.Status.Validate(); + _ = this.ParameterDefinitions; } public BillableMetric() { } diff --git a/src/Orb/Models/PriceInterval.cs b/src/Orb/Models/PriceInterval.cs index a741eabf8..e4015b947 100644 --- a/src/Orb/Models/PriceInterval.cs +++ b/src/Orb/Models/PriceInterval.cs @@ -192,6 +192,28 @@ public required IReadOnlyList? UsageCustomerIds } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// public override void Validate() { @@ -209,6 +231,7 @@ public override void Validate() this.Price.Validate(); _ = this.StartDate; _ = this.UsageCustomerIds; + _ = this.MetricParameterOverrides; } public PriceInterval() { } diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs index 70ad1f8fc..dead5094a 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -295,6 +295,28 @@ public IReadOnlyList? GroupingKeys } } + /// + /// Optional overrides for parameterized billable metric parameters. If the metric + /// has parameter definitions and no overrides are provided, defaults will be used. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// New floating price request body params. /// @@ -327,6 +349,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.Filter; _ = this.GroupingKeys; + _ = this.MetricParameterOverrides; this.Price?.Validate(); _ = this.PriceID; } diff --git a/src/Orb/Models/Prices/PriceEvaluateParams.cs b/src/Orb/Models/Prices/PriceEvaluateParams.cs index b315a5b72..5c632719d 100644 --- a/src/Orb/Models/Prices/PriceEvaluateParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateParams.cs @@ -140,6 +140,28 @@ public IReadOnlyList? GroupingKeys } } + /// + /// Optional overrides for parameterized billable metric parameters. If the metric + /// has parameter definitions and no overrides are provided, defaults will be used. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawBodyData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + public PriceEvaluateParams() { } #pragma warning disable CS8618 diff --git a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs index aef8c60b9..4b9811f33 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs @@ -441,6 +441,28 @@ public IReadOnlyList? GroupingKeys } } + /// + /// Optional overrides for parameterized billable metric parameters. If the metric + /// has parameter definitions and no overrides are provided, defaults will be used. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// New floating price request body params. /// @@ -475,6 +497,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.Filter; _ = this.GroupingKeys; + _ = this.MetricParameterOverrides; this.Price?.Validate(); _ = this.PriceID; } diff --git a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs index d4291b423..79fb6c016 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -1526,6 +1526,28 @@ public string? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount /// for this price. @@ -1606,6 +1628,7 @@ public override void Validate() _ = this.EndDate; _ = this.ExternalPriceID; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; _ = this.PlanPhaseOrder; this.Price?.Validate(); @@ -10276,6 +10299,28 @@ public string? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount /// for the replacement price. @@ -10329,6 +10374,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; this.Price?.Validate(); _ = this.PriceID; diff --git a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index 34d9fdbdb..57830167f 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -484,6 +484,28 @@ public double? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values (number or string). + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// The minimum amount that will be billed for this price interval for a given /// billing period. @@ -566,6 +588,7 @@ public override void Validate() item.Validate(); } _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; this.Price?.Validate(); _ = this.PriceID; @@ -10000,6 +10023,28 @@ public IReadOnlyList? FixedFeeQuantityTransition } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values (number or string). + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// The updated start date of this price interval. If not specified, the start /// date will not be updated. @@ -10058,6 +10103,7 @@ public override void Validate() { item.Validate(); } + _ = this.MetricParameterOverrides; this.StartDate?.Validate(); _ = this.UsageCustomerIds; } diff --git a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs index 90ca7ecef..598917d88 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -1520,6 +1520,28 @@ public string? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount /// for this price. @@ -1602,6 +1624,7 @@ public override void Validate() _ = this.EndDate; _ = this.ExternalPriceID; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; _ = this.PlanPhaseOrder; this.Price?.Validate(); @@ -10992,6 +11015,28 @@ public string? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount /// for the replacement price. @@ -11047,6 +11092,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; this.Price?.Validate(); _ = this.PriceID; From 716231cde616767e62affe993d4251d2897daaf2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 01:22:38 +0000 Subject: [PATCH 26/39] feat(api): api update --- .stats.yml | 4 ++-- .../LedgerCreateEntryByExternalIDParams.cs | 10 ++++++---- .../Credits/Ledger/LedgerCreateEntryParams.cs | 10 ++++++---- .../Services/Customers/Credits/ILedgerService.cs | 16 ++++++++++------ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2fd311799..d77036d15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-3c7ee3ec9931aaeeb5e015a598812cde9edc09f114adb8759ef4c2054c90f7dc.yml -openapi_spec_hash: a14720041156fe4f353449142edacf0d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-563cf1475c193333d5f8cab934fbf844e439db6218c5b9eccb089b5c1d797b4b.yml +openapi_spec_hash: f2b06aac248aecb248e975af25f3911c config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index c7d9f09d2..1b752cb6c 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -49,8 +49,10 @@ namespace Orb.Models.Customers.Credits.Ledger; /// body of this request, Orb will also generate a one-off invoice for the customer /// for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, /// since the total charges on the invoice are calculated by multiplying the cost -/// basis with the number of credit units added. Additionally, Orb also enforces -/// invoice generation when a non-zero `per_unit_cost_basis` value is provided. +/// basis with the number of credit units added. * if `per_unit_cost_basis` is greater +/// than zero, an invoice will be generated and `invoice_settings` must be included +/// * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` +/// is required to determine the due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer by /// creating an entry of type `decrement`. Orb matches the algorithm for automatic @@ -1415,8 +1417,8 @@ public string? Memo /// based on the invoice or issuance date, depending on the account's configured /// due date calculation method. A value of '0' here represents that the invoice /// is due on issue, whereas a value of '30' represents that the customer has - /// 30 days to pay the invoice. Do not set this field if you want to set a custom - /// due date. + /// 30 days to pay the invoice. You must set either `net_terms` or `custom_due_date`, + /// but not both. /// public long? NetTerms { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index 246f9540c..f01db85fb 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -49,8 +49,10 @@ namespace Orb.Models.Customers.Credits.Ledger; /// body of this request, Orb will also generate a one-off invoice for the customer /// for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, /// since the total charges on the invoice are calculated by multiplying the cost -/// basis with the number of credit units added. Additionally, Orb also enforces -/// invoice generation when a non-zero `per_unit_cost_basis` value is provided. +/// basis with the number of credit units added. * if `per_unit_cost_basis` is greater +/// than zero, an invoice will be generated and `invoice_settings` must be included +/// * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` +/// is required to determine the due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer by /// creating an entry of type `decrement`. Orb matches the algorithm for automatic @@ -1274,8 +1276,8 @@ public string? Memo /// based on the invoice or issuance date, depending on the account's configured /// due date calculation method. A value of '0' here represents that the invoice /// is due on issue, whereas a value of '30' represents that the customer has - /// 30 days to pay the invoice. Do not set this field if you want to set a custom - /// due date. + /// 30 days to pay the invoice. You must set either `net_terms` or `custom_due_date`, + /// but not both. /// public long? NetTerms { diff --git a/src/Orb/Services/Customers/Credits/ILedgerService.cs b/src/Orb/Services/Customers/Credits/ILedgerService.cs index e97ffac9f..fc72503c8 100644 --- a/src/Orb/Services/Customers/Credits/ILedgerService.cs +++ b/src/Orb/Services/Customers/Credits/ILedgerService.cs @@ -147,9 +147,11 @@ Task List( /// in the body of this request, Orb will also generate a one-off invoice for /// the customer for the credits pre-purchase. Note that you _must_ provide the /// `per_unit_cost_basis`, since the total charges on the invoice are calculated - /// by multiplying the cost basis with the number of credit units added. Additionally, - /// Orb also enforces invoice generation when a non-zero `per_unit_cost_basis` - /// value is provided. + /// by multiplying the cost basis with the number of credit units added. * if + /// `per_unit_cost_basis` is greater than zero, an invoice will be generated + /// and `invoice_settings` must be included * if `invoice_settings` is passed, + /// one of either `custom_due_date` or `net_terms` is required to determine the + /// due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic @@ -247,9 +249,11 @@ Task CreateEntry( /// in the body of this request, Orb will also generate a one-off invoice for /// the customer for the credits pre-purchase. Note that you _must_ provide the /// `per_unit_cost_basis`, since the total charges on the invoice are calculated - /// by multiplying the cost basis with the number of credit units added. Additionally, - /// Orb also enforces invoice generation when a non-zero `per_unit_cost_basis` - /// value is provided. + /// by multiplying the cost basis with the number of credit units added. * if + /// `per_unit_cost_basis` is greater than zero, an invoice will be generated + /// and `invoice_settings` must be included * if `invoice_settings` is passed, + /// one of either `custom_due_date` or `net_terms` is required to determine the + /// due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic From 72cfd078f36c6087b0ce6c30037dd2fe2d9d1d7d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 16:36:10 +0000 Subject: [PATCH 27/39] chore: update mock server docs --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 00e368982..9f50ad392 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,7 @@ "postAttachCommand": "cat .vscode/extensions.json | jq -r .recommendations[] | xargs -n 1 code --install-extension", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "features": { - // For the Prism mock server. + // For the mock server. "ghcr.io/devcontainers/features/node:1": {} } } From a198566976ed1faab7db589e8755162e567ee70f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Feb 2026 22:41:13 +0000 Subject: [PATCH 28/39] refactor(internal): default headers --- src/Orb/Core/ParamsBase.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Orb/Core/ParamsBase.cs b/src/Orb/Core/ParamsBase.cs index 6554ac027..e66b4a4b4 100644 --- a/src/Orb/Core/ParamsBase.cs +++ b/src/Orb/Core/ParamsBase.cs @@ -203,6 +203,13 @@ internal static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions static string GetUserAgent() => $"{typeof(OrbClient).Name}/C# {GetPackageVersion()}"; + static string GetPackageVersion() => + Assembly + .GetExecutingAssembly() + .GetCustomAttribute() + ?.InformationalVersion + ?? "unknown"; + static string GetOSArch() => RuntimeInformation.OSArchitecture switch { @@ -237,13 +244,6 @@ static string GetOS() return $"Other:{RuntimeInformation.OSDescription}"; } - static string GetPackageVersion() => - Assembly - .GetExecutingAssembly() - .GetCustomAttribute() - ?.InformationalVersion - ?? "unknown"; - static Runtime GetRuntime() { var runtimeDescription = RuntimeInformation.FrameworkDescription; From f26879d5478ff24192dd4e4700016da4da6d879c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 02:22:37 +0000 Subject: [PATCH 29/39] feat(api): api update --- .stats.yml | 4 +-- .../Beta/BetaCreatePlanVersionParamsTest.cs | 4 +++ ...ternalPlanIDCreatePlanVersionParamsTest.cs | 4 +++ src/Orb.Tests/Models/Items/ItemTest.cs | 2 ++ .../Models/Items/ItemUpdateParamsTest.cs | 2 ++ ...gScalableMatrixWithUnitPricingPriceTest.cs | 26 +++++++++++++++++ ...nScalableMatrixWithUnitPricingPriceTest.cs | 26 +++++++++++++++++ .../Models/Plans/PlanCreateParamsTest.cs | 2 ++ src/Orb.Tests/Models/PriceTest.cs | 28 +++++++++++++++++++ .../Models/Prices/PriceCreateParamsTest.cs | 2 ++ .../Prices/PriceEvaluateMultipleParamsTest.cs | 2 ++ .../PriceEvaluatePreviewEventsParamsTest.cs | 2 ++ ...nScalableMatrixWithUnitPricingPriceTest.cs | 26 +++++++++++++++++ .../SubscriptionCreateParamsTest.cs | 4 +++ .../SubscriptionPriceIntervalsParamsTest.cs | 2 ++ ...ubscriptionSchedulePlanChangeParamsTest.cs | 4 +++ src/Orb/Models/Items/Item.cs | 3 ++ src/Orb/Models/Items/ItemUpdateParams.cs | 3 ++ ...atingScalableMatrixWithUnitPricingPrice.cs | 14 ++++++++++ ...wPlanScalableMatrixWithUnitPricingPrice.cs | 14 ++++++++++ src/Orb/Models/Price.cs | 14 ++++++++++ ...ptionScalableMatrixWithUnitPricingPrice.cs | 14 ++++++++++ 22 files changed, 200 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d77036d15..add28a88b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-563cf1475c193333d5f8cab934fbf844e439db6218c5b9eccb089b5c1d797b4b.yml -openapi_spec_hash: f2b06aac248aecb248e975af25f3911c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-0186c0310e2a9f40302cc35f4248fca335b7ec8069502f684ba6f2fa37793033.yml +openapi_spec_hash: 4fb1d2837ad3794864a7d59d393d6ff6 config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs index 5ac690a72..770e1a60b 100644 --- a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs @@ -3240,6 +3240,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4926,6 +4927,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -13175,6 +13177,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -14933,6 +14936,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs index 94311dd35..0123694ae 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs @@ -3251,6 +3251,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4937,6 +4938,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -13186,6 +13188,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -14944,6 +14947,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb.Tests/Models/Items/ItemTest.cs b/src/Orb.Tests/Models/Items/ItemTest.cs index 05a9c5e06..6ffe3de58 100644 --- a/src/Orb.Tests/Models/Items/ItemTest.cs +++ b/src/Orb.Tests/Models/Items/ItemTest.cs @@ -389,6 +389,7 @@ public class ItemExternalConnectionExternalConnectionNameTest : TestBase [InlineData(ItemExternalConnectionExternalConnectionName.Avalara)] [InlineData(ItemExternalConnectionExternalConnectionName.Anrok)] [InlineData(ItemExternalConnectionExternalConnectionName.Numeral)] + [InlineData(ItemExternalConnectionExternalConnectionName.StripeTax)] public void Validation_Works(ItemExternalConnectionExternalConnectionName rawValue) { // force implicit conversion because Theory can't do that for us @@ -416,6 +417,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(ItemExternalConnectionExternalConnectionName.Avalara)] [InlineData(ItemExternalConnectionExternalConnectionName.Anrok)] [InlineData(ItemExternalConnectionExternalConnectionName.Numeral)] + [InlineData(ItemExternalConnectionExternalConnectionName.StripeTax)] public void SerializationRoundtrip_Works(ItemExternalConnectionExternalConnectionName rawValue) { // force implicit conversion because Theory can't do that for us diff --git a/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs b/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs index 41619753f..5c18118be 100644 --- a/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs @@ -223,6 +223,7 @@ public class ExternalConnectionNameTest : TestBase [InlineData(ExternalConnectionName.Avalara)] [InlineData(ExternalConnectionName.Anrok)] [InlineData(ExternalConnectionName.Numeral)] + [InlineData(ExternalConnectionName.StripeTax)] public void Validation_Works(ExternalConnectionName rawValue) { // force implicit conversion because Theory can't do that for us @@ -251,6 +252,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(ExternalConnectionName.Avalara)] [InlineData(ExternalConnectionName.Anrok)] [InlineData(ExternalConnectionName.Numeral)] + [InlineData(ExternalConnectionName.StripeTax)] public void SerializationRoundtrip_Works(ExternalConnectionName rawValue) { // force implicit conversion because Theory can't do that for us diff --git a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs index 818a6de33..9535863fa 100644 --- a/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewFloatingScalableMatrixWithUnitPricingPriceTest.cs @@ -32,6 +32,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -86,6 +87,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -174,6 +176,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -242,6 +245,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -304,6 +308,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -395,6 +400,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -456,6 +462,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -511,6 +518,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -543,6 +551,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -611,6 +620,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -656,6 +666,7 @@ public void CopyConstructor_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -836,6 +847,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -851,6 +863,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -861,6 +874,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); Assert.Equal(expectedProrate, model.Prorate); Assert.Equal(expectedSecondDimension, model.SecondDimension); } @@ -881,6 +895,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -910,6 +925,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -932,6 +948,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -942,6 +959,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); Assert.Equal(expectedProrate, deserialized.Prorate); Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); } @@ -962,6 +980,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -987,6 +1006,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() UnitPrice = "unit_price", }; + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.False(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -1031,10 +1052,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.True(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -1058,6 +1082,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; @@ -1081,6 +1106,7 @@ public void CopyConstructor_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; diff --git a/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs index d19fd1672..1a7d0b576 100644 --- a/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/NewPlanScalableMatrixWithUnitPricingPriceTest.cs @@ -31,6 +31,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -87,6 +88,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -177,6 +179,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -245,6 +248,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -308,6 +312,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -401,6 +406,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -463,6 +469,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -521,6 +528,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -552,6 +560,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -625,6 +634,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -671,6 +681,7 @@ public void CopyConstructor_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -850,6 +861,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -865,6 +877,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -875,6 +888,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); Assert.Equal(expectedProrate, model.Prorate); Assert.Equal(expectedSecondDimension, model.SecondDimension); } @@ -895,6 +909,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -925,6 +940,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -948,6 +964,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -958,6 +975,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); Assert.Equal(expectedProrate, deserialized.Prorate); Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); } @@ -978,6 +996,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -1003,6 +1022,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() UnitPrice = "unit_price", }; + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.False(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -1047,10 +1068,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.True(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -1074,6 +1098,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; @@ -1097,6 +1122,7 @@ public void CopyConstructor_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; diff --git a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs index 76efdc31c..fc051e4ec 100644 --- a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs @@ -2790,6 +2790,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4548,6 +4549,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb.Tests/Models/PriceTest.cs b/src/Orb.Tests/Models/PriceTest.cs index 17f17612a..5a3cb86ad 100644 --- a/src/Orb.Tests/Models/PriceTest.cs +++ b/src/Orb.Tests/Models/PriceTest.cs @@ -3120,6 +3120,7 @@ public void ScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -7070,6 +7071,7 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -60572,6 +60574,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -60714,6 +60717,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -60889,6 +60893,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -61029,6 +61034,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -61178,6 +61184,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -61356,6 +61363,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -61490,6 +61498,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -61616,6 +61625,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -61739,6 +61749,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -61868,6 +61879,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -61994,6 +62006,7 @@ public void CopyConstructor_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -62520,6 +62533,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -62535,6 +62549,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -62545,6 +62560,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); Assert.Equal(expectedProrate, model.Prorate); Assert.Equal(expectedSecondDimension, model.SecondDimension); } @@ -62565,6 +62581,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -62595,6 +62612,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -62618,6 +62636,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -62628,6 +62647,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); Assert.Equal(expectedProrate, deserialized.Prorate); Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); } @@ -62648,6 +62668,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -62673,6 +62694,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() UnitPrice = "unit_price", }; + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.False(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -62717,10 +62740,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.True(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -62744,6 +62770,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; @@ -62767,6 +62794,7 @@ public void CopyConstructor_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; diff --git a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs index 8b2dc15ce..33ba1c5f8 100644 --- a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs @@ -1451,6 +1451,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3111,6 +3112,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceSerializationRoundtripW }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs index 15d9598cb..1c4ce9217 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs @@ -2398,6 +2398,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4058,6 +4059,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs index 7f313247f..1a6420dca 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs @@ -2715,6 +2715,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4508,6 +4509,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs index 10be34dce..1e2aca428 100644 --- a/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.cs @@ -33,6 +33,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -95,6 +96,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -186,6 +188,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -256,6 +259,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -326,6 +330,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -420,6 +425,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -483,6 +489,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -542,6 +549,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -574,6 +582,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -648,6 +657,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -695,6 +705,7 @@ public void CopyConstructor_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -905,6 +916,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -920,6 +932,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -930,6 +943,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); Assert.Equal(expectedProrate, model.Prorate); Assert.Equal(expectedSecondDimension, model.SecondDimension); } @@ -950,6 +964,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -980,6 +995,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -1003,6 +1019,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -1013,6 +1030,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); Assert.Equal(expectedProrate, deserialized.Prorate); Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); } @@ -1033,6 +1051,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -1058,6 +1077,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() UnitPrice = "unit_price", }; + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.False(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -1102,10 +1123,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.True(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -1129,6 +1153,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; @@ -1152,6 +1177,7 @@ public void CopyConstructor_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs index e4f1c1683..11dbc6028 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs @@ -4478,6 +4478,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -6261,6 +6262,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -14714,6 +14716,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -16524,6 +16527,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs index ab5170bce..4da3e6cac 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs @@ -3481,6 +3481,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -5208,6 +5209,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs index dbdd1bd90..21ef5f879 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs @@ -3977,6 +3977,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -5827,6 +5828,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -14932,6 +14934,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -16782,6 +16785,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, diff --git a/src/Orb/Models/Items/Item.cs b/src/Orb/Models/Items/Item.cs index decfb3311..34fe0816c 100644 --- a/src/Orb/Models/Items/Item.cs +++ b/src/Orb/Models/Items/Item.cs @@ -260,6 +260,7 @@ public enum ItemExternalConnectionExternalConnectionName Avalara, Anrok, Numeral, + StripeTax, } sealed class ItemExternalConnectionExternalConnectionNameConverter @@ -281,6 +282,7 @@ JsonSerializerOptions options "avalara" => ItemExternalConnectionExternalConnectionName.Avalara, "anrok" => ItemExternalConnectionExternalConnectionName.Anrok, "numeral" => ItemExternalConnectionExternalConnectionName.Numeral, + "stripe_tax" => ItemExternalConnectionExternalConnectionName.StripeTax, _ => (ItemExternalConnectionExternalConnectionName)(-1), }; } @@ -303,6 +305,7 @@ JsonSerializerOptions options ItemExternalConnectionExternalConnectionName.Avalara => "avalara", ItemExternalConnectionExternalConnectionName.Anrok => "anrok", ItemExternalConnectionExternalConnectionName.Numeral => "numeral", + ItemExternalConnectionExternalConnectionName.StripeTax => "stripe_tax", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Items/ItemUpdateParams.cs b/src/Orb/Models/Items/ItemUpdateParams.cs index 6eff09064..9410a54d1 100644 --- a/src/Orb/Models/Items/ItemUpdateParams.cs +++ b/src/Orb/Models/Items/ItemUpdateParams.cs @@ -289,6 +289,7 @@ public enum ExternalConnectionName Avalara, Anrok, Numeral, + StripeTax, } sealed class ExternalConnectionNameConverter : JsonConverter @@ -309,6 +310,7 @@ JsonSerializerOptions options "avalara" => ExternalConnectionName.Avalara, "anrok" => ExternalConnectionName.Anrok, "numeral" => ExternalConnectionName.Numeral, + "stripe_tax" => ExternalConnectionName.StripeTax, _ => (ExternalConnectionName)(-1), }; } @@ -331,6 +333,7 @@ JsonSerializerOptions options ExternalConnectionName.Avalara => "avalara", ExternalConnectionName.Anrok => "anrok", ExternalConnectionName.Numeral => "numeral", + ExternalConnectionName.StripeTax => "stripe_tax", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs index 6e5dbbfc1..3d9053006 100644 --- a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs @@ -510,6 +510,19 @@ public required string UnitPrice init { this._rawData.Set("unit_price", value); } } + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + /// /// If true, the unit price will be prorated to the billing period /// @@ -545,6 +558,7 @@ public override void Validate() item.Validate(); } _ = this.UnitPrice; + _ = this.GroupingKey; _ = this.Prorate; _ = this.SecondDimension; } diff --git a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs index 42e143de5..458db8a0d 100644 --- a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs @@ -524,6 +524,19 @@ public required string UnitPrice init { this._rawData.Set("unit_price", value); } } + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + /// /// If true, the unit price will be prorated to the billing period /// @@ -559,6 +572,7 @@ public override void Validate() item.Validate(); } _ = this.UnitPrice; + _ = this.GroupingKey; _ = this.Prorate; _ = this.SecondDimension; } diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index f2c720976..8dad84b83 100644 --- a/src/Orb/Models/Price.cs +++ b/src/Orb/Models/Price.cs @@ -36046,6 +36046,19 @@ public required string UnitPrice init { this._rawData.Set("unit_price", value); } } + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + /// /// If true, the unit price will be prorated to the billing period /// @@ -36081,6 +36094,7 @@ public override void Validate() item.Validate(); } _ = this.UnitPrice; + _ = this.GroupingKey; _ = this.Prorate; _ = this.SecondDimension; } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs index 8d2fc7720..0c890415e 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs @@ -530,6 +530,19 @@ public required string UnitPrice init { this._rawData.Set("unit_price", value); } } + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + /// /// If true, the unit price will be prorated to the billing period /// @@ -565,6 +578,7 @@ public override void Validate() item.Validate(); } _ = this.UnitPrice; + _ = this.GroupingKey; _ = this.Prorate; _ = this.SecondDimension; } From e4ce03dc208398d10aa351959e9b9cf8d679672d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 15:26:23 +0000 Subject: [PATCH 30/39] chore(docs): add proxy documentation to readme --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 9837e0837..ed3d1549f 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,26 @@ var customer = await client Console.WriteLine(customer); ``` +### Proxies + +To route requests through a proxy, configure your client with a custom [`HttpClient`](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-10.0): + +```csharp +using System.Net; +using System.Net.Http; +using Orb; + +var httpClient = new HttpClient +( + new HttpClientHandler + { + Proxy = new WebProxy("https://example.com:8080") + } +); + +OrbClient client = new() { HttpClient = httpClient }; +``` + ## Undocumented API functionality The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. From c984acb5f59fb3935e80abe786a1634465e862fe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:58:01 +0000 Subject: [PATCH 31/39] chore(docs): add undocumented parameters to readme --- README.md | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/README.md b/README.md index ed3d1549f..d5603157f 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,119 @@ OrbClient client = new() { HttpClient = httpClient }; The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. +### Parameters + +To set undocumented parameters, a constructor exists that accepts dictionaries for additional header, query, and body values. If the method type doesn't support request bodies (e.g. `GET` requests), the constructor will only accept a header and query dictionary. + +```csharp +using System.Collections.Generic; +using System.Text.Json; +using Orb.Models.Customers; + +CustomerCreateParams parameters = new +( + rawHeaderData: new Dictionary() + { + { "Custom-Header", JsonSerializer.SerializeToElement(42) } + }, + + rawQueryData: new Dictionary() + { + { "custom_query_param", JsonSerializer.SerializeToElement(42) } + }, + + rawBodyData: new Dictionary() + { + { "custom_body_param", JsonSerializer.SerializeToElement(42) } + } +) +{ + // Documented properties can still be added here. + // In case of conflict, these parameters take precedence over the custom parameters. + AutoCollection = true +}; +``` + +The raw parameters can also be accessed through the `RawHeaderData`, `RawQueryData`, and `RawBodyData` (if available) properties. + +This can also be used to set a documented parameter to an undocumented or not yet supported _value_, as long as the parameter is optional. If the parameter is required, omitting its `init` property will result in a compile-time error. To work around this, the `FromRawUnchecked` method can be used: + +```csharp +using System.Collections.Generic; +using System.Text.Json; +using Orb.Models.Customers; + +var parameters = CustomerCreateParams.FromRawUnchecked +( + + rawHeaderData: new Dictionary(), + rawQueryData: new Dictionary(), + rawBodyData: new Dictionary + { + { + "email", + JsonSerializer.SerializeToElement("custom value") + } + } +); +``` + +### Nested Parameters + +Undocumented properties, or undocumented values of documented properties, on nested parameters can be set similarly, using a dictionary in the constructor of the nested parameter. + +```csharp +using System.Collections.Generic; +using System.Text.Json; +using Orb.Models.Customers; + +CustomerCreateParams parameters = new() +{ + AccountingSyncConfiguration = new + ( + new Dictionary + { + { "custom_nested_param", JsonSerializer.SerializeToElement(42) } + } + ) +}; +``` + +Required properties on the nested parameter can also be changed or omitted using the `FromRawUnchecked` method: + +```csharp +using System.Collections.Generic; +using System.Text.Json; +using Orb.Models.Customers; + +CustomerCreateParams parameters = new() +{ + AccountingSyncConfiguration = NewAccountingSyncConfiguration.FromRawUnchecked + ( + new Dictionary + { + { "required_property", JsonSerializer.SerializeToElement("custom value") } + } + ) +}; +``` + +### Response properties + +To access undocumented response properties, the `RawData` property can be used: + +```csharp +using System.Text.Json; + +var response = client.Customers.Create(parameters) +if (response.RawData.TryGetValue("my_custom_key", out JsonElement value)) +{ + // Do something with `value` +} +``` + +`RawData` is a `IReadonlyDictionary`. It holds the full data received from the API server. + ### Response validation In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `string`, but the API could return something else. From e99472a25dbbc10db210c0f54234fc5c2a26b25e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Feb 2026 23:06:54 +0000 Subject: [PATCH 32/39] chore(docs): add missing descriptions --- .../Services/Beta/IExternalPlanIDService.cs | 10 ++++++--- .../Services/Coupons/ISubscriptionService.cs | 11 +++++++--- .../Customers/Credits/ILedgerService.cs | 9 +++++--- .../Customers/Credits/ITopUpService.cs | 9 +++++--- .../Customers/IBalanceTransactionService.cs | 22 ++++++++++++++++--- src/Orb/Services/Customers/ICostService.cs | 22 ++++++++++++++++--- src/Orb/Services/Customers/ICreditService.cs | 9 +++++--- src/Orb/Services/Events/IBackfillService.cs | 10 ++++++--- src/Orb/Services/Events/IVolumeService.cs | 10 ++++++--- src/Orb/Services/IAlertService.cs | 11 +++++++--- src/Orb/Services/IBetaService.cs | 10 ++++++--- src/Orb/Services/ICouponService.cs | 11 +++++++--- src/Orb/Services/ICreditBlockService.cs | 9 +++++--- src/Orb/Services/ICreditNoteService.cs | 9 +++++--- src/Orb/Services/ICustomerService.cs | 22 ++++++++++++++++--- src/Orb/Services/IEventService.cs | 10 ++++++--- src/Orb/Services/IInvoiceLineItemService.cs | 12 +++++++--- src/Orb/Services/IInvoiceService.cs | 12 +++++++--- src/Orb/Services/IItemService.cs | 10 ++++++--- src/Orb/Services/ILicenseTypeService.cs | 10 ++++++--- src/Orb/Services/IMetricService.cs | 10 ++++++--- src/Orb/Services/IPlanService.cs | 10 ++++++--- src/Orb/Services/IPriceService.cs | 16 +++++++++++--- .../Services/Plans/IExternalPlanIDService.cs | 10 ++++++--- src/Orb/Services/Plans/IMigrationService.cs | 10 ++++++--- .../Prices/IExternalPriceIDService.cs | 16 +++++++++++--- 26 files changed, 232 insertions(+), 78 deletions(-) diff --git a/src/Orb/Services/Beta/IExternalPlanIDService.cs b/src/Orb/Services/Beta/IExternalPlanIDService.cs index d79a4a269..dc5191a17 100644 --- a/src/Orb/Services/Beta/IExternalPlanIDService.cs +++ b/src/Orb/Services/Beta/IExternalPlanIDService.cs @@ -9,9 +9,13 @@ namespace Orb.Services.Beta; /// -/// 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. +/// The [Plan](/core-concepts#plan-and-price) resource represents a plan that can +/// be subscribed to by a customer. Plans define the billing behavior of the subscription. +/// You can see more about how to configure prices in the [Price resource](/reference/price). +/// +/// 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 interface IExternalPlanIDService { diff --git a/src/Orb/Services/Coupons/ISubscriptionService.cs b/src/Orb/Services/Coupons/ISubscriptionService.cs index a86ee0cc8..8c5be5ac5 100644 --- a/src/Orb/Services/Coupons/ISubscriptionService.cs +++ b/src/Orb/Services/Coupons/ISubscriptionService.cs @@ -7,9 +7,14 @@ namespace Orb.Services.Coupons; /// -/// 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. +/// A coupon represents a reusable discount configuration that can be applied either +/// as a fixed or percentage amount to an invoice or subscription. Coupons are activated +/// using a redemption code, which applies the discount to a subscription or invoice. +/// The duration of a coupon determines how long it remains available for use by end users. +/// +/// 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 interface ISubscriptionService { diff --git a/src/Orb/Services/Customers/Credits/ILedgerService.cs b/src/Orb/Services/Customers/Credits/ILedgerService.cs index fc72503c8..8de37cfa5 100644 --- a/src/Orb/Services/Customers/Credits/ILedgerService.cs +++ b/src/Orb/Services/Customers/Credits/ILedgerService.cs @@ -7,9 +7,12 @@ namespace Orb.Services.Customers.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. +/// The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid +/// credits within Orb. +/// +/// 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 interface ILedgerService { diff --git a/src/Orb/Services/Customers/Credits/ITopUpService.cs b/src/Orb/Services/Customers/Credits/ITopUpService.cs index c7f766c6d..b7567e889 100644 --- a/src/Orb/Services/Customers/Credits/ITopUpService.cs +++ b/src/Orb/Services/Customers/Credits/ITopUpService.cs @@ -7,9 +7,12 @@ namespace Orb.Services.Customers.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. +/// The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid +/// credits within Orb. +/// +/// 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 interface ITopUpService { diff --git a/src/Orb/Services/Customers/IBalanceTransactionService.cs b/src/Orb/Services/Customers/IBalanceTransactionService.cs index c2ab67eab..40dfea54e 100644 --- a/src/Orb/Services/Customers/IBalanceTransactionService.cs +++ b/src/Orb/Services/Customers/IBalanceTransactionService.cs @@ -7,9 +7,25 @@ namespace Orb.Services.Customers; /// -/// 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. +/// A customer is a buyer of your products, and the other party to the billing relationship. +/// +/// In Orb, customers are assigned system generated identifiers automatically, +/// but it's often desirable to have these match existing identifiers in your system. +/// To avoid having to denormalize Orb ID information, you can pass in an `external_customer_id` +/// with your own identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) +/// for further information about how these aliases work in Orb. +/// +/// In addition to having an identifier in your system, a customer may exist +/// in a payment provider solution like Stripe. Use the `payment_provider_id` and +/// the `payment_provider` enum field to express this mapping. +/// +/// A customer also has a timezone (from the standard [IANA timezone database](https://www.iana.org/time-zones)), +/// which defaults to your account's timezone. See [Timezone localization](/essentials/timezones) +/// for information on what this timezone parameter influences within Orb. +/// +/// 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 interface IBalanceTransactionService { diff --git a/src/Orb/Services/Customers/ICostService.cs b/src/Orb/Services/Customers/ICostService.cs index 6aeaf9461..5b3e849d1 100644 --- a/src/Orb/Services/Customers/ICostService.cs +++ b/src/Orb/Services/Customers/ICostService.cs @@ -7,9 +7,25 @@ namespace Orb.Services.Customers; /// -/// 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. +/// A customer is a buyer of your products, and the other party to the billing relationship. +/// +/// In Orb, customers are assigned system generated identifiers automatically, +/// but it's often desirable to have these match existing identifiers in your system. +/// To avoid having to denormalize Orb ID information, you can pass in an `external_customer_id` +/// with your own identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) +/// for further information about how these aliases work in Orb. +/// +/// In addition to having an identifier in your system, a customer may exist +/// in a payment provider solution like Stripe. Use the `payment_provider_id` and +/// the `payment_provider` enum field to express this mapping. +/// +/// A customer also has a timezone (from the standard [IANA timezone database](https://www.iana.org/time-zones)), +/// which defaults to your account's timezone. See [Timezone localization](/essentials/timezones) +/// for information on what this timezone parameter influences within Orb. +/// +/// 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 interface ICostService { diff --git a/src/Orb/Services/Customers/ICreditService.cs b/src/Orb/Services/Customers/ICreditService.cs index 3419b7bc6..6e8d320c6 100644 --- a/src/Orb/Services/Customers/ICreditService.cs +++ b/src/Orb/Services/Customers/ICreditService.cs @@ -8,9 +8,12 @@ namespace Orb.Services.Customers; /// -/// 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. +/// The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid +/// credits within Orb. +/// +/// 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 interface ICreditService { diff --git a/src/Orb/Services/Events/IBackfillService.cs b/src/Orb/Services/Events/IBackfillService.cs index 5cbafef73..fc97ec115 100644 --- a/src/Orb/Services/Events/IBackfillService.cs +++ b/src/Orb/Services/Events/IBackfillService.cs @@ -7,9 +7,13 @@ namespace Orb.Services.Events; /// -/// 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. +/// The [Event](/core-concepts#event) resource represents a usage event that has been +/// created for a customer. Events are the core of Orb's usage-based billing model, +/// and are used to calculate the usage charges for a given 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 interface IBackfillService { diff --git a/src/Orb/Services/Events/IVolumeService.cs b/src/Orb/Services/Events/IVolumeService.cs index 4f42b7a76..0444741b2 100644 --- a/src/Orb/Services/Events/IVolumeService.cs +++ b/src/Orb/Services/Events/IVolumeService.cs @@ -7,9 +7,13 @@ namespace Orb.Services.Events; /// -/// 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. +/// The [Event](/core-concepts#event) resource represents a usage event that has been +/// created for a customer. Events are the core of Orb's usage-based billing model, +/// and are used to calculate the usage charges for a given 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 interface IVolumeService { diff --git a/src/Orb/Services/IAlertService.cs b/src/Orb/Services/IAlertService.cs index fe2b3ae13..27fa225d4 100644 --- a/src/Orb/Services/IAlertService.cs +++ b/src/Orb/Services/IAlertService.cs @@ -7,9 +7,14 @@ namespace Orb.Services; /// -/// 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. +/// [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, +/// or credit balance and trigger webhooks when a threshold is exceeded. +/// +/// Alerts created through the API can be scoped to either customers or subscriptions. +/// +/// 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 interface IAlertService { diff --git a/src/Orb/Services/IBetaService.cs b/src/Orb/Services/IBetaService.cs index 4b42c1c9d..162d924e8 100644 --- a/src/Orb/Services/IBetaService.cs +++ b/src/Orb/Services/IBetaService.cs @@ -9,9 +9,13 @@ namespace Orb.Services; /// -/// 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. +/// The [Plan](/core-concepts#plan-and-price) resource represents a plan that can +/// be subscribed to by a customer. Plans define the billing behavior of the subscription. +/// You can see more about how to configure prices in the [Price resource](/reference/price). +/// +/// 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 interface IBetaService { diff --git a/src/Orb/Services/ICouponService.cs b/src/Orb/Services/ICouponService.cs index bb02e0542..9c82d6999 100644 --- a/src/Orb/Services/ICouponService.cs +++ b/src/Orb/Services/ICouponService.cs @@ -8,9 +8,14 @@ namespace Orb.Services; /// -/// 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. +/// A coupon represents a reusable discount configuration that can be applied either +/// as a fixed or percentage amount to an invoice or subscription. Coupons are activated +/// using a redemption code, which applies the discount to a subscription or invoice. +/// The duration of a coupon determines how long it remains available for use by end users. +/// +/// 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 interface ICouponService { diff --git a/src/Orb/Services/ICreditBlockService.cs b/src/Orb/Services/ICreditBlockService.cs index 4c952dc61..c429ae258 100644 --- a/src/Orb/Services/ICreditBlockService.cs +++ b/src/Orb/Services/ICreditBlockService.cs @@ -7,9 +7,12 @@ namespace Orb.Services; /// -/// 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. +/// The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid +/// credits within Orb. +/// +/// 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 interface ICreditBlockService { diff --git a/src/Orb/Services/ICreditNoteService.cs b/src/Orb/Services/ICreditNoteService.cs index beb374383..cab63e38a 100644 --- a/src/Orb/Services/ICreditNoteService.cs +++ b/src/Orb/Services/ICreditNoteService.cs @@ -8,9 +8,12 @@ namespace Orb.Services; /// -/// 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. +/// The [Credit Note](/invoicing/credit-notes) resource represents a credit that +/// has been applied to a particular 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 interface ICreditNoteService { diff --git a/src/Orb/Services/ICustomerService.cs b/src/Orb/Services/ICustomerService.cs index a284faac1..7d1f14dd7 100644 --- a/src/Orb/Services/ICustomerService.cs +++ b/src/Orb/Services/ICustomerService.cs @@ -8,9 +8,25 @@ namespace Orb.Services; /// -/// 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. +/// A customer is a buyer of your products, and the other party to the billing relationship. +/// +/// In Orb, customers are assigned system generated identifiers automatically, +/// but it's often desirable to have these match existing identifiers in your system. +/// To avoid having to denormalize Orb ID information, you can pass in an `external_customer_id` +/// with your own identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) +/// for further information about how these aliases work in Orb. +/// +/// In addition to having an identifier in your system, a customer may exist +/// in a payment provider solution like Stripe. Use the `payment_provider_id` and +/// the `payment_provider` enum field to express this mapping. +/// +/// A customer also has a timezone (from the standard [IANA timezone database](https://www.iana.org/time-zones)), +/// which defaults to your account's timezone. See [Timezone localization](/essentials/timezones) +/// for information on what this timezone parameter influences within Orb. +/// +/// 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 interface ICustomerService { diff --git a/src/Orb/Services/IEventService.cs b/src/Orb/Services/IEventService.cs index 5a1400051..e2fe01f60 100644 --- a/src/Orb/Services/IEventService.cs +++ b/src/Orb/Services/IEventService.cs @@ -8,9 +8,13 @@ namespace Orb.Services; /// -/// 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. +/// The [Event](/core-concepts#event) resource represents a usage event that has been +/// created for a customer. Events are the core of Orb's usage-based billing model, +/// and are used to calculate the usage charges for a given 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 interface IEventService { diff --git a/src/Orb/Services/IInvoiceLineItemService.cs b/src/Orb/Services/IInvoiceLineItemService.cs index d4cd93aa6..fe33f47d5 100644 --- a/src/Orb/Services/IInvoiceLineItemService.cs +++ b/src/Orb/Services/IInvoiceLineItemService.cs @@ -7,9 +7,15 @@ namespace Orb.Services; /// -/// 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. +/// An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing +/// the request for payment for a single subscription. This includes a set of line +/// items, which correspond to prices in the subscription's plan and can represent +/// fixed recurring fees or usage-based fees. They are generated at the end of a +/// billing period, or as the result of an action, such as a cancellation. +/// +/// 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 interface IInvoiceLineItemService { diff --git a/src/Orb/Services/IInvoiceService.cs b/src/Orb/Services/IInvoiceService.cs index ee5112f24..eb3b9875d 100644 --- a/src/Orb/Services/IInvoiceService.cs +++ b/src/Orb/Services/IInvoiceService.cs @@ -8,9 +8,15 @@ namespace Orb.Services; /// -/// 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. +/// An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing +/// the request for payment for a single subscription. This includes a set of line +/// items, which correspond to prices in the subscription's plan and can represent +/// fixed recurring fees or usage-based fees. They are generated at the end of a +/// billing period, or as the result of an action, such as a cancellation. +/// +/// 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 interface IInvoiceService { diff --git a/src/Orb/Services/IItemService.cs b/src/Orb/Services/IItemService.cs index 12955b7fb..76893a929 100644 --- a/src/Orb/Services/IItemService.cs +++ b/src/Orb/Services/IItemService.cs @@ -7,9 +7,13 @@ namespace Orb.Services; /// -/// 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. +/// The Item resource represents a sellable product or good. Items are associated +/// with all line items, billable metrics, and prices and are used for defining external +/// sync behavior for invoices and tax calculation purposes. +/// +/// 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 interface IItemService { diff --git a/src/Orb/Services/ILicenseTypeService.cs b/src/Orb/Services/ILicenseTypeService.cs index 393e2e02b..7113aff52 100644 --- a/src/Orb/Services/ILicenseTypeService.cs +++ b/src/Orb/Services/ILicenseTypeService.cs @@ -7,9 +7,13 @@ namespace Orb.Services; /// -/// 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. +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +/// 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 interface ILicenseTypeService { diff --git a/src/Orb/Services/IMetricService.cs b/src/Orb/Services/IMetricService.cs index bd2f397af..a4f298ed1 100644 --- a/src/Orb/Services/IMetricService.cs +++ b/src/Orb/Services/IMetricService.cs @@ -7,9 +7,13 @@ namespace Orb.Services; /// -/// 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. +/// The Metric resource represents a calculation of a quantity based on events. Metrics +/// are defined by the query that transforms raw usage events into meaningful values +/// for your customers. +/// +/// 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 interface IMetricService { diff --git a/src/Orb/Services/IPlanService.cs b/src/Orb/Services/IPlanService.cs index e7eac2227..1a1695631 100644 --- a/src/Orb/Services/IPlanService.cs +++ b/src/Orb/Services/IPlanService.cs @@ -8,9 +8,13 @@ namespace Orb.Services; /// -/// 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. +/// The [Plan](/core-concepts#plan-and-price) resource represents a plan that can +/// be subscribed to by a customer. Plans define the billing behavior of the subscription. +/// You can see more about how to configure prices in the [Price resource](/reference/price). +/// +/// 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 interface IPlanService { diff --git a/src/Orb/Services/IPriceService.cs b/src/Orb/Services/IPriceService.cs index 0cf829df2..6257ab547 100644 --- a/src/Orb/Services/IPriceService.cs +++ b/src/Orb/Services/IPriceService.cs @@ -9,9 +9,19 @@ namespace Orb.Services; /// -/// 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. +/// The Price resource represents a price that can be billed on a subscription, resulting +/// in a charge on an invoice in the form of an invoice line item. Prices take a quantity +/// and determine an amount to bill. +/// +/// Orb supports a few different pricing models out of the box. Each of these +/// models is serialized differently in a given Price object. The model_type field +/// determines the key for the configuration object that is present. +/// +/// For more on the types of prices, see [the core concepts documentation](/core-concepts#plan-and-price) +/// +/// 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 interface IPriceService { diff --git a/src/Orb/Services/Plans/IExternalPlanIDService.cs b/src/Orb/Services/Plans/IExternalPlanIDService.cs index 0ee64b546..c4f73b81b 100644 --- a/src/Orb/Services/Plans/IExternalPlanIDService.cs +++ b/src/Orb/Services/Plans/IExternalPlanIDService.cs @@ -8,9 +8,13 @@ namespace Orb.Services.Plans; /// -/// 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. +/// The [Plan](/core-concepts#plan-and-price) resource represents a plan that can +/// be subscribed to by a customer. Plans define the billing behavior of the subscription. +/// You can see more about how to configure prices in the [Price resource](/reference/price). +/// +/// 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 interface IExternalPlanIDService { diff --git a/src/Orb/Services/Plans/IMigrationService.cs b/src/Orb/Services/Plans/IMigrationService.cs index 67a93560b..93ebd4854 100644 --- a/src/Orb/Services/Plans/IMigrationService.cs +++ b/src/Orb/Services/Plans/IMigrationService.cs @@ -7,9 +7,13 @@ namespace Orb.Services.Plans; /// -/// 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. +/// The [Plan](/core-concepts#plan-and-price) resource represents a plan that can +/// be subscribed to by a customer. Plans define the billing behavior of the subscription. +/// You can see more about how to configure prices in the [Price resource](/reference/price). +/// +/// 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 interface IMigrationService { diff --git a/src/Orb/Services/Prices/IExternalPriceIDService.cs b/src/Orb/Services/Prices/IExternalPriceIDService.cs index 0307b3e80..7991143b6 100644 --- a/src/Orb/Services/Prices/IExternalPriceIDService.cs +++ b/src/Orb/Services/Prices/IExternalPriceIDService.cs @@ -8,9 +8,19 @@ namespace Orb.Services.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. +/// The Price resource represents a price that can be billed on a subscription, resulting +/// in a charge on an invoice in the form of an invoice line item. Prices take a quantity +/// and determine an amount to bill. +/// +/// Orb supports a few different pricing models out of the box. Each of these +/// models is serialized differently in a given Price object. The model_type field +/// determines the key for the configuration object that is present. +/// +/// For more on the types of prices, see [the core concepts documentation](/core-concepts#plan-and-price) +/// +/// 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 interface IExternalPriceIDService { From 582022798674964e95d81598f8a039df8aa57c99 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Feb 2026 23:22:48 +0000 Subject: [PATCH 33/39] feat(api): api update --- .stats.yml | 4 +-- .../Invoices/InvoiceCreateParamsTest.cs | 11 ++++++++ .../Invoices/InvoiceUpdateParamsTest.cs | 9 +++++++ .../Models/Invoices/InvoiceCreateParams.cs | 15 +++++++++++ .../Models/Invoices/InvoiceUpdateParams.cs | 25 +++++++++++++++---- src/Orb/Services/IInvoiceService.cs | 9 ++++--- 6 files changed, 62 insertions(+), 11 deletions(-) diff --git a/.stats.yml b/.stats.yml index add28a88b..2be12a8b5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-0186c0310e2a9f40302cc35f4248fca335b7ec8069502f684ba6f2fa37793033.yml -openapi_spec_hash: 4fb1d2837ad3794864a7d59d393d6ff6 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-5bb582f84f0b4cf7bef84833fefd48a5f2734dc25805da2028fd8a6f1198da07.yml +openapi_spec_hash: ced0e30dc67faa2414df511819408f12 config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs index c62ba2824..639f8a732 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs @@ -30,6 +30,7 @@ public void FieldRoundtrip_Works() UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ], + AutoCollection = true, CustomerID = "4khy3nwzktxv7", Discount = new Models::PercentageDiscount() { @@ -70,6 +71,7 @@ public void FieldRoundtrip_Works() UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ]; + bool expectedAutoCollection = true; string expectedCustomerID = "4khy3nwzktxv7"; Models::SharedDiscount expectedDiscount = new Models::PercentageDiscount() { @@ -101,6 +103,7 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedLineItems[i], parameters.LineItems[i]); } + Assert.Equal(expectedAutoCollection, parameters.AutoCollection); Assert.Equal(expectedCustomerID, parameters.CustomerID); Assert.Equal(expectedDiscount, parameters.Discount); Assert.Equal(expectedDueDate, parameters.DueDate); @@ -138,6 +141,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ], + AutoCollection = true, CustomerID = "4khy3nwzktxv7", Discount = new Models::PercentageDiscount() { @@ -186,6 +190,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ], + AutoCollection = true, CustomerID = "4khy3nwzktxv7", Discount = new Models::PercentageDiscount() { @@ -240,6 +245,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() WillAutoIssue = false, }; + Assert.Null(parameters.AutoCollection); + Assert.False(parameters.RawBodyData.ContainsKey("auto_collection")); Assert.Null(parameters.CustomerID); Assert.False(parameters.RawBodyData.ContainsKey("customer_id")); Assert.Null(parameters.Discount); @@ -278,6 +285,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() ], WillAutoIssue = false, + AutoCollection = null, CustomerID = null, Discount = null, DueDate = null, @@ -287,6 +295,8 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() NetTerms = null, }; + Assert.Null(parameters.AutoCollection); + Assert.True(parameters.RawBodyData.ContainsKey("auto_collection")); Assert.Null(parameters.CustomerID); Assert.True(parameters.RawBodyData.ContainsKey("customer_id")); Assert.Null(parameters.Discount); @@ -350,6 +360,7 @@ public void CopyConstructor_Works() UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ], + AutoCollection = true, CustomerID = "4khy3nwzktxv7", Discount = new Models::PercentageDiscount() { diff --git a/src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs index b7ad75e42..6b67b8b9b 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs @@ -14,6 +14,7 @@ public void FieldRoundtrip_Works() var parameters = new InvoiceUpdateParams { InvoiceID = "invoice_id", + AutoCollection = true, DueDate = "2023-09-22", InvoiceDate = "2023-09-22", Metadata = new Dictionary() { { "foo", "string" } }, @@ -21,12 +22,14 @@ public void FieldRoundtrip_Works() }; string expectedInvoiceID = "invoice_id"; + bool expectedAutoCollection = true; InvoiceUpdateParamsDueDate expectedDueDate = "2023-09-22"; InvoiceDate expectedInvoiceDate = "2023-09-22"; Dictionary expectedMetadata = new() { { "foo", "string" } }; long expectedNetTerms = 0; Assert.Equal(expectedInvoiceID, parameters.InvoiceID); + Assert.Equal(expectedAutoCollection, parameters.AutoCollection); Assert.Equal(expectedDueDate, parameters.DueDate); Assert.Equal(expectedInvoiceDate, parameters.InvoiceDate); Assert.NotNull(parameters.Metadata); @@ -45,6 +48,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() { var parameters = new InvoiceUpdateParams { InvoiceID = "invoice_id" }; + Assert.Null(parameters.AutoCollection); + Assert.False(parameters.RawBodyData.ContainsKey("auto_collection")); Assert.Null(parameters.DueDate); Assert.False(parameters.RawBodyData.ContainsKey("due_date")); Assert.Null(parameters.InvoiceDate); @@ -62,12 +67,15 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() { InvoiceID = "invoice_id", + AutoCollection = null, DueDate = null, InvoiceDate = null, Metadata = null, NetTerms = null, }; + Assert.Null(parameters.AutoCollection); + Assert.True(parameters.RawBodyData.ContainsKey("auto_collection")); Assert.Null(parameters.DueDate); Assert.True(parameters.RawBodyData.ContainsKey("due_date")); Assert.Null(parameters.InvoiceDate); @@ -94,6 +102,7 @@ public void CopyConstructor_Works() var parameters = new InvoiceUpdateParams { InvoiceID = "invoice_id", + AutoCollection = true, DueDate = "2023-09-22", InvoiceDate = "2023-09-22", Metadata = new Dictionary() { { "foo", "string" } }, diff --git a/src/Orb/Models/Invoices/InvoiceCreateParams.cs b/src/Orb/Models/Invoices/InvoiceCreateParams.cs index dbdf29c80..5e89a0a47 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -71,6 +71,21 @@ public required IReadOnlyList LineItems } } + /// + /// Determines whether this invoice will automatically attempt to charge a saved + /// payment method, if any. If not specified, the invoice inherits the customer's + /// auto_collection setting. + /// + public bool? AutoCollection + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("auto_collection"); + } + init { this._rawBodyData.Set("auto_collection", value); } + } + /// /// The id of the `Customer` to create this invoice for. One of `customer_id` /// and `external_customer_id` are required. diff --git a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs index c06a5a2bc..5b4359f85 100644 --- a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs @@ -12,13 +12,13 @@ namespace Orb.Models.Invoices; /// -/// This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and -/// `invoice_date` properties on an invoice. If you pass null for the metadata value, -/// it will clear any existing metadata for that invoice. +/// This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, +/// and `auto_collection` properties on an invoice. If you pass null for the metadata +/// value, it will clear any existing metadata for that invoice. /// /// `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. +/// `invoice_date`, and `auto_collection` 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 @@ -34,6 +34,21 @@ public IReadOnlyDictionary RawBodyData public string? InvoiceID { get; init; } + /// + /// Determines whether this invoice will automatically attempt to charge a saved + /// payment method, if any. Can only be modified on draft invoices. If not specified, + /// the invoice's existing setting is unchanged. + /// + public bool? AutoCollection + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("auto_collection"); + } + init { this._rawBodyData.Set("auto_collection", value); } + } + /// /// An optional custom due date for the invoice. If not set, the due date will /// be calculated based on the `net_terms` value. diff --git a/src/Orb/Services/IInvoiceService.cs b/src/Orb/Services/IInvoiceService.cs index eb3b9875d..72a0cf00d 100644 --- a/src/Orb/Services/IInvoiceService.cs +++ b/src/Orb/Services/IInvoiceService.cs @@ -43,12 +43,13 @@ Task Create( /// /// This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, - /// and `invoice_date` properties on an invoice. If you pass null for the metadata - /// value, it will clear any existing metadata for that invoice. + /// `invoice_date`, and `auto_collection` properties on an invoice. If you pass + /// null for the metadata value, it will clear any existing metadata for that invoice. /// /// `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. + /// `due_date`, `invoice_date`, and `auto_collection` can only be modified if + /// the invoice is in a `draft` state. `invoice_date` can only be modified for + /// non-subscription invoices. /// Task Update( InvoiceUpdateParams parameters, From e90a3c65eb8c36a7016a1673f3afd3bfb04487bf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 06:14:01 +0000 Subject: [PATCH 34/39] chore(tests): add tests for retry logic --- src/Orb.Tests/Orb.Tests.csproj | 1 + src/Orb.Tests/RetriesTest.cs | 418 +++++++++++++++++++++++++++++++++ src/Orb/OrbClient.cs | 6 +- 3 files changed, 424 insertions(+), 1 deletion(-) create mode 100644 src/Orb.Tests/RetriesTest.cs diff --git a/src/Orb.Tests/Orb.Tests.csproj b/src/Orb.Tests/Orb.Tests.csproj index 00c667950..eaec279f8 100644 --- a/src/Orb.Tests/Orb.Tests.csproj +++ b/src/Orb.Tests/Orb.Tests.csproj @@ -14,6 +14,7 @@ + diff --git a/src/Orb.Tests/RetriesTest.cs b/src/Orb.Tests/RetriesTest.cs new file mode 100644 index 000000000..d28131a5e --- /dev/null +++ b/src/Orb.Tests/RetriesTest.cs @@ -0,0 +1,418 @@ +using System; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Moq; +using Moq.Protected; +using Orb; +using Orb.Core; + +namespace Orb.Tests; + +public class RetriesTest : TestBase +{ + record class BlankParams : ParamsBase + { + internal override void AddHeadersToRequest( + HttpRequestMessage _request, + ClientOptions _options + ) + { + // do nothing + } + + public override Uri Url(ClientOptions _options) + { + return new Uri("http://localhost/something"); + } + } + + record class ParamsWithOverwrittenRetryHeader : ParamsBase + { + internal override void AddHeadersToRequest( + HttpRequestMessage request, + ClientOptions _options + ) + { + request.Headers.TryAddWithoutValidation("x-stainless-retry-count", "42"); + } + + public override Uri Url(ClientOptions _options) + { + return new Uri("http://localhost/something"); + } + } + + [Fact] + public async Task ImmediateSuccess_Works() + { + var handlerMock = new Mock(); + handlerMock + .Protected() + .Setup>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + OrbClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Get, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task RetryAfterHeader_Works() + { + var ResponseWithRetryDate = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.ServiceUnavailable, + Content = new StringContent("foo"), + }; + ResponseWithRetryDate.Headers.Add("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT"); + + var ResponseWithRetryDelay = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.ServiceUnavailable, + Content = new StringContent("foo"), + }; + // decimals are technically out of spec, but we want to ensure we can parse them regardless + ResponseWithRetryDelay.Headers.TryAddWithoutValidation("Retry-After", "1.234"); + + var handlerMock = new Mock(); + handlerMock + .Protected() + .SetupSequence>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync(ResponseWithRetryDate) + .ReturnsAsync(ResponseWithRetryDelay) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + OrbClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Get, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "0" + ), + ItExpr.IsAny() + ); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "1" + ), + ItExpr.IsAny() + ); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "2" + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task IdempotencyHeader_Works() + { + string? headerValue = null; + + var callCount = 0; + + var handlerMock = new Mock(); + handlerMock + .Protected() + .Setup>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .Returns( + (req, _) => + { + headerValue ??= Enumerable.Single(req.Headers.GetValues("Idempotency-Key")); + + return Task.FromResult( + new HttpResponseMessage() + { + StatusCode = + callCount++ == 0 + ? HttpStatusCode.ServiceUnavailable + : HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + OrbClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Post, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(2), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Post + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("Idempotency-Key")) + == headerValue + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task OverwrittenRetryCountHeader_Works() + { + var handlerMock = new Mock(); + handlerMock + .Protected() + .SetupSequence>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.ServiceUnavailable, + Content = new StringContent("foo"), + } + ) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + OrbClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest + { + Method = HttpMethod.Get, + Params = new(), + }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(2), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "42" + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task RetryAfterMsHeader_Works() + { + var failResponse = new HttpResponseMessage() + { + StatusCode = HttpStatusCode.ServiceUnavailable, + Content = new StringContent("foo"), + }; + failResponse.Headers.TryAddWithoutValidation("Retry-After-Ms", "10"); + + var handlerMock = new Mock(); + handlerMock + .Protected() + .SetupSequence>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync(failResponse) + .ReturnsAsync( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + OrbClient client = new() { HttpClient = httpClient, MaxRetries = 1 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Get, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(2), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + ), + ItExpr.IsAny() + ); + } + + [Fact] + public async Task RetryableException_Works() + { + var callCount = 0; + + var handlerMock = new Mock(); + handlerMock + .Protected() + .Setup>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .Returns( + (_, ct) => + { + callCount++; + if (callCount == 1) + throw new HttpRequestException("Simulated retryable failure"); + + return Task.FromResult( + new HttpResponseMessage() + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent("foo"), + } + ); + } + ); + + var httpClient = new HttpClient(handlerMock.Object); + + OrbClient client = new() { HttpClient = httpClient, MaxRetries = 2 }; + + var resp = await client.WithRawResponse.Execute( + new HttpRequest { Method = HttpMethod.Get, Params = new() }, + TestContext.Current.CancellationToken + ); + + Assert.Equal(HttpStatusCode.OK, resp.StatusCode); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "0" + ), + ItExpr.IsAny() + ); + handlerMock + .Protected() + .Verify( + "SendAsync", + Times.Exactly(1), + ItExpr.Is( + (req) => + req.Method == HttpMethod.Get + && req.RequestUri == new Uri("http://localhost/something") + && Enumerable.Single(req.Headers.GetValues("x-stainless-retry-count")) + == "1" + ), + ItExpr.IsAny() + ); + } +} diff --git a/src/Orb/OrbClient.cs b/src/Orb/OrbClient.cs index ebdebeb8c..874a57e98 100644 --- a/src/Orb/OrbClient.cs +++ b/src/Orb/OrbClient.cs @@ -526,7 +526,11 @@ async Task ExecuteOnce( static TimeSpan ComputeRetryBackoff(int retries, HttpResponse? response) { TimeSpan? apiBackoff = ParseRetryAfterMsHeader(response) ?? ParseRetryAfterHeader(response); - if (apiBackoff != null && apiBackoff < TimeSpan.FromMinutes(1)) + if ( + apiBackoff != null + && apiBackoff > TimeSpan.Zero + && apiBackoff < TimeSpan.FromMinutes(1) + ) { // If the API asks us to wait a certain amount of time (and it's a reasonable amount), then just // do what it says. From 5c40cf77147cf374d8df1cf69f593ede2966ba9d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Mar 2026 02:40:08 +0000 Subject: [PATCH 35/39] docs: remove typo in README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d5603157f..88b538324 100644 --- a/README.md +++ b/README.md @@ -140,8 +140,6 @@ The SDK throws custom unchecked exception types: Additionally, all 4xx errors inherit from `Orb4xxException`. -false - - `OrbIOException`: I/O networking errors. - `OrbInvalidDataException`: Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. From 2ee5350e955b6ce5bb90932e250390c1bbd5983c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 04:23:42 +0000 Subject: [PATCH 36/39] feat(api): api update --- .stats.yml | 4 +- .../Beta/BetaCreatePlanVersionParamsTest.cs | 87577 +++++++++++++++- ...ternalPlanIDCreatePlanVersionParamsTest.cs | 87577 +++++++++++++++- .../Models/Plans/PlanCreateParamsTest.cs | 42396 +++++++- src/Orb.Tests/Services/PlanServiceTest.cs | 50 + src/Orb/Core/ModelBase.cs | 323 + .../Beta/BetaCreatePlanVersionParams.cs | 70916 ++++++++++++- .../ExternalPlanIDCreatePlanVersionParams.cs | 70916 ++++++++++++- .../LedgerCreateEntryByExternalIDParams.cs | 10 +- .../Credits/Ledger/LedgerCreateEntryParams.cs | 10 +- src/Orb/Models/Plans/PlanCreateParams.cs | 33545 +++++- .../Customers/Credits/ILedgerService.cs | 24 +- 12 files changed, 382438 insertions(+), 10910 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2be12a8b5..95afb0ace 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-5bb582f84f0b4cf7bef84833fefd48a5f2734dc25805da2028fd8a6f1198da07.yml -openapi_spec_hash: ced0e30dc67faa2414df511819408f12 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-dafe9f726a47bdf7e506af8f10c6abcf4321dcc58106ce2b806a918778dfe2be.yml +openapi_spec_hash: 8e9827f2e8818d011e6afb203adb825f config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs index 770e1a60b..97a685bc0 100644 --- a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs @@ -73,6 +73,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -176,6 +224,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -279,6 +375,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -387,6 +531,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -600,6 +792,54 @@ public void CopyConstructor_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -703,6 +943,54 @@ public void CopyConstructor_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1426,12 +1714,60 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + LicenseAllocationPrice = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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", @@ -1493,6 +1829,53 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; long expectedPlanPhaseOrder = 0; Price expectedPrice = new Models::NewPlanUnitPrice() { @@ -1535,6 +1918,7 @@ public void FieldRoundtrip_Works() }; Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, model.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPrice, model.Price); } @@ -1568,6 +1952,54 @@ public void SerializationRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1646,6 +2078,54 @@ public void FieldRoundtripThroughSerialization_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1720,6 +2200,53 @@ public void FieldRoundtripThroughSerialization_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; long expectedPlanPhaseOrder = 0; Price expectedPrice = new Models::NewPlanUnitPrice() { @@ -1762,6 +2289,7 @@ public void FieldRoundtripThroughSerialization_Works() }; Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, deserialized.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPrice, deserialized.Price); } @@ -1795,6 +2323,54 @@ public void Validation_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1848,6 +2424,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.AllocationPrice); Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.False(model.RawData.ContainsKey("license_allocation_price")); Assert.Null(model.PlanPhaseOrder); Assert.False(model.RawData.ContainsKey("plan_phase_order")); Assert.Null(model.Price); @@ -1868,12 +2446,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new AddPrice { AllocationPrice = null, + LicenseAllocationPrice = null, PlanPhaseOrder = null, Price = null, }; Assert.Null(model.AllocationPrice); Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.True(model.RawData.ContainsKey("license_allocation_price")); Assert.Null(model.PlanPhaseOrder); Assert.True(model.RawData.ContainsKey("plan_phase_order")); Assert.Null(model.Price); @@ -1886,6 +2467,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new AddPrice { AllocationPrice = null, + LicenseAllocationPrice = null, PlanPhaseOrder = null, Price = null, }; @@ -1922,6 +2504,54 @@ public void CopyConstructor_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1971,16 +2601,24 @@ public void CopyConstructor_Works() } } -public class PriceTest : TestBase +public class LicenseAllocationPriceTest : TestBase { [Fact] - public void NewPlanUnitValidationWorks() + public void UnitValidationWorks() { - Price value = new Models::NewPlanUnitPrice() + LicenseAllocationPrice value = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", @@ -2019,13 +2657,21 @@ public void NewPlanUnitValidationWorks() } [Fact] - public void NewPlanTieredValidationWorks() + public void TieredValidationWorks() { - Price value = new Models::NewPlanTieredPrice() + LicenseAllocationPrice value = new Tiered() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredConfig = new() { @@ -2076,14 +2722,22 @@ public void NewPlanTieredValidationWorks() } [Fact] - public void NewPlanBulkValidationWorks() + public void BulkValidationWorks() { - Price value = new Models::NewPlanBulkPrice() + LicenseAllocationPrice value = new Bulk() { BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = BulkCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2123,7 +2777,7 @@ public void NewPlanBulkValidationWorks() [Fact] public void BulkWithFiltersValidationWorks() { - Price value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -2134,8 +2788,17 @@ public void BulkWithFiltersValidationWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2173,13 +2836,21 @@ public void BulkWithFiltersValidationWorks() } [Fact] - public void NewPlanPackageValidationWorks() + public void PackageValidationWorks() { - Price value = new Models::NewPlanPackagePrice() + LicenseAllocationPrice value = new Package() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", @@ -2218,19 +2889,27 @@ public void NewPlanPackageValidationWorks() } [Fact] - public void NewPlanMatrixValidationWorks() + public void MatrixValidationWorks() { - Price value = new Models::NewPlanMatrixPrice() + LicenseAllocationPrice value = new Matrix() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = MatrixCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixConfig = new() { DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2268,13 +2947,21 @@ public void NewPlanMatrixValidationWorks() } [Fact] - public void NewPlanThresholdTotalAmountValidationWorks() + public void ThresholdTotalAmountValidationWorks() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + LicenseAllocationPrice value = new ThresholdTotalAmount() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = ThresholdTotalAmountCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ThresholdTotalAmountConfig = new() { @@ -2321,13 +3008,21 @@ public void NewPlanThresholdTotalAmountValidationWorks() } [Fact] - public void NewPlanTieredPackageValidationWorks() + public void TieredPackageValidationWorks() { - Price value = new Models::NewPlanTieredPackagePrice() + LicenseAllocationPrice value = new TieredPackage() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = TieredPackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredPackageConfig = new() { @@ -2374,13 +3069,21 @@ public void NewPlanTieredPackageValidationWorks() } [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void TieredWithMinimumValidationWorks() { - Price value = new Models::NewPlanTieredWithMinimumPrice() + LicenseAllocationPrice value = new TieredWithMinimum() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithMinimumConfig = new() { @@ -2438,11 +3141,11 @@ public void NewPlanTieredWithMinimumValidationWorks() } [Fact] - public void NewPlanGroupedTieredValidationWorks() + public void GroupedTieredValidationWorks() { - Price value = new Models::NewPlanGroupedTieredPrice() + LicenseAllocationPrice value = new GroupedTiered() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + Cadence = GroupedTieredCadence.Annual, GroupedTieredConfig = new() { GroupingKey = "x", @@ -2453,7 +3156,15 @@ public void NewPlanGroupedTieredValidationWorks() ], }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2491,14 +3202,21 @@ public void NewPlanGroupedTieredValidationWorks() } [Fact] - public void NewPlanTieredPackageWithMinimumValidationWorks() + public void TieredPackageWithMinimumValidationWorks() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + LicenseAllocationPrice value = new TieredPackageWithMinimum() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredPackageWithMinimumConfig = new() { @@ -2555,13 +3273,21 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() } [Fact] - public void NewPlanPackageWithAllocationValidationWorks() + public void PackageWithAllocationValidationWorks() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + LicenseAllocationPrice value = new PackageWithAllocation() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PackageWithAllocationConfig = new() { @@ -2605,13 +3331,21 @@ public void NewPlanPackageWithAllocationValidationWorks() } [Fact] - public void NewPlanUnitWithPercentValidationWorks() + public void UnitWithPercentValidationWorks() { - Price value = new Models::NewPlanUnitWithPercentPrice() + LicenseAllocationPrice value = new UnitWithPercent() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = UnitWithPercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", @@ -2650,12 +3384,21 @@ public void NewPlanUnitWithPercentValidationWorks() } [Fact] - public void NewPlanMatrixWithAllocationValidationWorks() + public void MatrixWithAllocationValidationWorks() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + LicenseAllocationPrice value = new MatrixWithAllocation() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = MatrixWithAllocationCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixWithAllocationConfig = new() { Allocation = "allocation", @@ -2663,7 +3406,6 @@ public void NewPlanMatrixWithAllocationValidationWorks() Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2703,10 +3445,19 @@ public void NewPlanMatrixWithAllocationValidationWorks() [Fact] public void TieredWithProrationValidationWorks() { - Price value = new TieredWithProration() + LicenseAllocationPrice value = new TieredWithProration() { Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithProrationConfig = new( [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] @@ -2747,13 +3498,21 @@ public void TieredWithProrationValidationWorks() } [Fact] - public void NewPlanUnitWithProrationValidationWorks() + public void UnitWithProrationValidationWorks() { - Price value = new Models::NewPlanUnitWithProrationPrice() + LicenseAllocationPrice value = new UnitWithProration() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = UnitWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", @@ -2792,11 +3551,11 @@ public void NewPlanUnitWithProrationValidationWorks() } [Fact] - public void NewPlanGroupedAllocationValidationWorks() + public void GroupedAllocationValidationWorks() { - Price value = new Models::NewPlanGroupedAllocationPrice() + LicenseAllocationPrice value = new GroupedAllocation() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + Cadence = GroupedAllocationCadence.Annual, GroupedAllocationConfig = new() { Allocation = "allocation", @@ -2804,7 +3563,15 @@ public void NewPlanGroupedAllocationValidationWorks() OverageUnitRate = "overage_unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2842,9 +3609,9 @@ public void NewPlanGroupedAllocationValidationWorks() } [Fact] - public void NewPlanBulkWithProrationValidationWorks() + public void BulkWithProrationValidationWorks() { - Price value = new Models::NewPlanBulkWithProrationPrice() + LicenseAllocationPrice value = new BulkWithProration() { BulkWithProrationConfig = new( [ @@ -2852,9 +3619,17 @@ public void NewPlanBulkWithProrationValidationWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ] ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = BulkWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2892,11 +3667,11 @@ public void NewPlanBulkWithProrationValidationWorks() } [Fact] - public void NewPlanGroupedWithProratedMinimumValidationWorks() + public void GroupedWithProratedMinimumValidationWorks() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + LicenseAllocationPrice value = new GroupedWithProratedMinimum() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + Cadence = GroupedWithProratedMinimumCadence.Annual, GroupedWithProratedMinimumConfig = new() { GroupingKey = "x", @@ -2904,8 +3679,15 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() UnitRate = "unit_rate", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2943,11 +3725,11 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() } [Fact] - public void NewPlanGroupedWithMeteredMinimumValidationWorks() + public void GroupedWithMeteredMinimumValidationWorks() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + LicenseAllocationPrice value = new GroupedWithMeteredMinimum() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + Cadence = GroupedWithMeteredMinimumCadence.Annual, GroupedWithMeteredMinimumConfig = new() { GroupingKey = "x", @@ -2955,17 +3737,24 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() PricingKey = "pricing_key", ScalingFactors = [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, ], ScalingKey = "scaling_key", UnitAmounts = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, ], }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3005,7 +3794,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() [Fact] public void GroupedWithMinMaxThresholdsValidationWorks() { - Price value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -3016,6 +3805,15 @@ public void GroupedWithMinMaxThresholdsValidationWorks() PerUnitRate = "per_unit_rate", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3053,12 +3851,21 @@ public void GroupedWithMinMaxThresholdsValidationWorks() } [Fact] - public void NewPlanMatrixWithDisplayNameValidationWorks() + public void MatrixWithDisplayNameValidationWorks() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + LicenseAllocationPrice value = new MatrixWithDisplayName() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = MatrixWithDisplayNameCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixWithDisplayNameConfig = new() { Dimension = "dimension", @@ -3072,7 +3879,6 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3110,11 +3916,11 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() } [Fact] - public void NewPlanGroupedTieredPackageValidationWorks() + public void GroupedTieredPackageValidationWorks() { - Price value = new Models::NewPlanGroupedTieredPackagePrice() + LicenseAllocationPrice value = new GroupedTieredPackage() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + Cadence = GroupedTieredPackageCadence.Annual, GroupedTieredPackageConfig = new() { GroupingKey = "x", @@ -3126,7 +3932,15 @@ public void NewPlanGroupedTieredPackageValidationWorks() ], }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3164,12 +3978,21 @@ public void NewPlanGroupedTieredPackageValidationWorks() } [Fact] - public void NewPlanMaxGroupTieredPackageValidationWorks() + public void MaxGroupTieredPackageValidationWorks() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + LicenseAllocationPrice value = new MaxGroupTieredPackage() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = MaxGroupTieredPackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MaxGroupTieredPackageConfig = new() { GroupingKey = "x", @@ -3180,7 +4003,6 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3218,14 +4040,21 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void ScalableMatrixWithUnitPricingValidationWorks() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + LicenseAllocationPrice value = new ScalableMatrixWithUnitPricing() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ScalableMatrixWithUnitPricingConfig = new() { @@ -3280,14 +4109,21 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void ScalableMatrixWithTieredPricingValidationWorks() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + LicenseAllocationPrice value = new ScalableMatrixWithTieredPricing() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ScalableMatrixWithTieredPricingConfig = new() { @@ -3344,11 +4180,11 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void CumulativeGroupedBulkValidationWorks() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + LicenseAllocationPrice value = new CumulativeGroupedBulk() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + Cadence = CumulativeGroupedBulkCadence.Annual, CumulativeGroupedBulkConfig = new() { DimensionValues = @@ -3363,7 +4199,15 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Group = "group", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3403,7 +4247,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() [Fact] public void CumulativeGroupedAllocationValidationWorks() { - Price value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -3414,6 +4258,15 @@ public void CumulativeGroupedAllocationValidationWorks() UnitAmount = "unit_amount", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3451,14 +4304,22 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void MinimumCompositeValidationWorks() { - Price value = new Models::NewPlanMinimumCompositePrice() + LicenseAllocationPrice value = new MinimumComposite() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = MinimumCompositeCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3498,10 +4359,19 @@ public void NewPlanMinimumCompositeValidationWorks() [Fact] public void PercentValidationWorks() { - Price value = new Percent() + LicenseAllocationPrice value = new Percent() { Cadence = PercentCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PercentConfig = new(0), BillableMetricID = "billable_metric_id", @@ -3542,7 +4412,7 @@ public void PercentValidationWorks() [Fact] public void EventOutputValidationWorks() { - Price value = new EventOutput() + LicenseAllocationPrice value = new EventOutput() { Cadence = EventOutputCadence.Annual, EventOutputConfig = new() @@ -3552,6 +4422,15 @@ public void EventOutputValidationWorks() GroupingKey = "grouping_key", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3589,13 +4468,21 @@ public void EventOutputValidationWorks() } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Price value = new Models::NewPlanUnitPrice() + LicenseAllocationPrice value = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", @@ -3631,19 +4518,30 @@ public void NewPlanUnitSerializationRoundtripWorks() 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 NewPlanTieredSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPrice() + LicenseAllocationPrice value = new Tiered() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredConfig = new() { @@ -3691,20 +4589,31 @@ public void NewPlanTieredSerializationRoundtripWorks() 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 NewPlanBulkSerializationRoundtripWorks() + public void BulkSerializationRoundtripWorks() { - Price value = new Models::NewPlanBulkPrice() + LicenseAllocationPrice value = new Bulk() { BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = BulkCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3739,7 +4648,10 @@ public void NewPlanBulkSerializationRoundtripWorks() 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); } @@ -3747,7 +4659,7 @@ public void NewPlanBulkSerializationRoundtripWorks() [Fact] public void BulkWithFiltersSerializationRoundtripWorks() { - Price value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -3758,8 +4670,17 @@ public void BulkWithFiltersSerializationRoundtripWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3794,19 +4715,30 @@ public void BulkWithFiltersSerializationRoundtripWorks() 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 NewPlanPackageSerializationRoundtripWorks() + public void PackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanPackagePrice() + LicenseAllocationPrice value = new Package() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", @@ -3842,25 +4774,36 @@ public void NewPlanPackageSerializationRoundtripWorks() 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 NewPlanMatrixSerializationRoundtripWorks() + public void MatrixSerializationRoundtripWorks() { - Price value = new Models::NewPlanMatrixPrice() + LicenseAllocationPrice value = new Matrix() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = MatrixCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixConfig = new() { DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3895,19 +4838,30 @@ public void NewPlanMatrixSerializationRoundtripWorks() 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void ThresholdTotalAmountSerializationRoundtripWorks() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + LicenseAllocationPrice value = new ThresholdTotalAmount() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = ThresholdTotalAmountCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ThresholdTotalAmountConfig = new() { @@ -3951,19 +4905,30 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() 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 NewPlanTieredPackageSerializationRoundtripWorks() + public void TieredPackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPackagePrice() + LicenseAllocationPrice value = new TieredPackage() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = TieredPackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredPackageConfig = new() { @@ -4007,19 +4972,30 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void TieredWithMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredWithMinimumPrice() + LicenseAllocationPrice value = new TieredWithMinimum() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithMinimumConfig = new() { @@ -4074,17 +5050,20 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() 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 NewPlanGroupedTieredSerializationRoundtripWorks() + public void GroupedTieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedTieredPrice() + LicenseAllocationPrice value = new GroupedTiered() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + Cadence = GroupedTieredCadence.Annual, GroupedTieredConfig = new() { GroupingKey = "x", @@ -4095,7 +5074,15 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() ], }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4130,20 +5117,30 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void TieredPackageWithMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + LicenseAllocationPrice value = new TieredPackageWithMinimum() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredPackageWithMinimumConfig = new() { @@ -4197,19 +5194,30 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void PackageWithAllocationSerializationRoundtripWorks() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + LicenseAllocationPrice value = new PackageWithAllocation() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PackageWithAllocationConfig = new() { @@ -4250,19 +5258,30 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() 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 NewPlanUnitWithPercentSerializationRoundtripWorks() + public void UnitWithPercentSerializationRoundtripWorks() { - Price value = new Models::NewPlanUnitWithPercentPrice() + LicenseAllocationPrice value = new UnitWithPercent() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = UnitWithPercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", @@ -4298,18 +5317,30 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() 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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void MatrixWithAllocationSerializationRoundtripWorks() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + LicenseAllocationPrice value = new MatrixWithAllocation() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = MatrixWithAllocationCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixWithAllocationConfig = new() { Allocation = "allocation", @@ -4317,7 +5348,6 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4352,7 +5382,10 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() 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); } @@ -4360,10 +5393,19 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() [Fact] public void TieredWithProrationSerializationRoundtripWorks() { - Price value = new TieredWithProration() + LicenseAllocationPrice value = new TieredWithProration() { Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithProrationConfig = new( [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] @@ -4401,19 +5443,30 @@ public void TieredWithProrationSerializationRoundtripWorks() 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + public void UnitWithProrationSerializationRoundtripWorks() { - Price value = new Models::NewPlanUnitWithProrationPrice() + LicenseAllocationPrice value = new UnitWithProration() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = UnitWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", @@ -4449,17 +5502,20 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() 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 NewPlanGroupedAllocationSerializationRoundtripWorks() + public void GroupedAllocationSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedAllocationPrice() + LicenseAllocationPrice value = new GroupedAllocation() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + Cadence = GroupedAllocationCadence.Annual, GroupedAllocationConfig = new() { Allocation = "allocation", @@ -4467,7 +5523,15 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() OverageUnitRate = "overage_unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4502,15 +5566,18 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() 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 NewPlanBulkWithProrationSerializationRoundtripWorks() + public void BulkWithProrationSerializationRoundtripWorks() { - Price value = new Models::NewPlanBulkWithProrationPrice() + LicenseAllocationPrice value = new BulkWithProration() { BulkWithProrationConfig = new( [ @@ -4518,9 +5585,17 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ] ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = BulkWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4555,17 +5630,20 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void GroupedWithProratedMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + LicenseAllocationPrice value = new GroupedWithProratedMinimum() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + Cadence = GroupedWithProratedMinimumCadence.Annual, GroupedWithProratedMinimumConfig = new() { GroupingKey = "x", @@ -4573,8 +5651,15 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() UnitRate = "unit_rate", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4609,17 +5694,20 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void GroupedWithMeteredMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + LicenseAllocationPrice value = new GroupedWithMeteredMinimum() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + Cadence = GroupedWithMeteredMinimumCadence.Annual, GroupedWithMeteredMinimumConfig = new() { GroupingKey = "x", @@ -4627,17 +5715,24 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() PricingKey = "pricing_key", ScalingFactors = [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, ], ScalingKey = "scaling_key", UnitAmounts = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, ], }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4672,7 +5767,10 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() 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); } @@ -4680,7 +5778,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() [Fact] public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - Price value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -4691,6 +5789,15 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() PerUnitRate = "per_unit_rate", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4725,18 +5832,30 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void MatrixWithDisplayNameSerializationRoundtripWorks() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + LicenseAllocationPrice value = new MatrixWithDisplayName() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = MatrixWithDisplayNameCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixWithDisplayNameConfig = new() { Dimension = "dimension", @@ -4750,7 +5869,6 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4785,17 +5903,20 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void GroupedTieredPackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedTieredPackagePrice() + LicenseAllocationPrice value = new GroupedTieredPackage() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + Cadence = GroupedTieredPackageCadence.Annual, GroupedTieredPackageConfig = new() { GroupingKey = "x", @@ -4807,7 +5928,15 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() ], }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4842,18 +5971,30 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void MaxGroupTieredPackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + LicenseAllocationPrice value = new MaxGroupTieredPackage() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = MaxGroupTieredPackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MaxGroupTieredPackageConfig = new() { GroupingKey = "x", @@ -4864,7 +6005,6 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4899,20 +6039,30 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + LicenseAllocationPrice value = new ScalableMatrixWithUnitPricing() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ScalableMatrixWithUnitPricingConfig = new() { @@ -4964,20 +6114,30 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + LicenseAllocationPrice value = new ScalableMatrixWithTieredPricing() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ScalableMatrixWithTieredPricingConfig = new() { @@ -5031,17 +6191,20 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() 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 NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void CumulativeGroupedBulkSerializationRoundtripWorks() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + LicenseAllocationPrice value = new CumulativeGroupedBulk() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + Cadence = CumulativeGroupedBulkCadence.Annual, CumulativeGroupedBulkConfig = new() { DimensionValues = @@ -5056,7 +6219,15 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Group = "group", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5091,7 +6262,10 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() 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); } @@ -5099,7 +6273,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() [Fact] public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -5110,6 +6284,15 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() UnitAmount = "unit_amount", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5144,20 +6327,31 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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 NewPlanMinimumCompositeSerializationRoundtripWorks() + public void MinimumCompositeSerializationRoundtripWorks() { - Price value = new Models::NewPlanMinimumCompositePrice() + LicenseAllocationPrice value = new MinimumComposite() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = MinimumCompositeCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5192,7 +6386,10 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() 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); } @@ -5200,10 +6397,19 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() [Fact] public void PercentSerializationRoundtripWorks() { - Price value = new Percent() + LicenseAllocationPrice value = new Percent() { Cadence = PercentCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PercentConfig = new(0), BillableMetricID = "billable_metric_id", @@ -5239,7 +6445,10 @@ public void PercentSerializationRoundtripWorks() 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); } @@ -5247,7 +6456,7 @@ public void PercentSerializationRoundtripWorks() [Fact] public void EventOutputSerializationRoundtripWorks() { - Price value = new EventOutput() + LicenseAllocationPrice value = new EventOutput() { Cadence = EventOutputCadence.Annual, EventOutputConfig = new() @@ -5257,6 +6466,15 @@ public void EventOutputSerializationRoundtripWorks() GroupingKey = "grouping_key", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5291,31 +6509,35 @@ public void EventOutputSerializationRoundtripWorks() 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 BulkWithFiltersTest : TestBase +public class UnitTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5349,19 +6571,24 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - 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 = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -5395,11 +6622,16 @@ 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitConfig, model.UnitConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -5426,20 +6658,21 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5474,10 +6707,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); } @@ -5485,20 +6715,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5533,25 +6764,27 @@ 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); - 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 = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -5585,11 +6818,16 @@ 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitConfig, deserialized.UnitConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -5619,20 +6857,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5672,20 +6911,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }; Assert.Null(model.BillableMetricID); @@ -5721,20 +6961,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }; model.Validate(); @@ -5743,20 +6984,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = null, BilledInAdvance = null, @@ -5807,20 +7049,21 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = null, BilledInAdvance = null, @@ -5844,20 +7087,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5891,223 +7135,114 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - BulkWithFilters copied = new(model); + Unit copied = new(model); Assert.Equal(model, copied); } } -public class BulkWithFiltersConfigTest : TestBase +public class CadenceTest : TestBase { - [Fact] - public void FieldRoundtrip_Works() + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void Validation_Works(Cadence rawValue) { - var model = new 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]); - } + // 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 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, + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void SerializationRoundtrip_Works(Cadence rawValue) { - var model = new BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, 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 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(); - } - - [Fact] - public void CopyConstructor_Works() - { - var model = new BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - BulkWithFiltersConfig copied = new(model); - - Assert.Equal(model, copied); - } -} - -public class FilterTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new 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 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 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 Filter { PropertyKey = "x", PropertyValue = "x" }; - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void CopyConstructor_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - Filter copied = new(model); + 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(model, copied); + Assert.Equal(value, deserialized); } } -public class TierTest : TestBase +public class LicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; 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); } @@ -6115,23 +7250,38 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; 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 expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } @@ -6139,16 +7289,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Tier { UnitAmount = "unit_amount" }; + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Tier { UnitAmount = "unit_amount" }; + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; model.Validate(); } @@ -6156,25 +7306,27 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Tier + var model = new LicenseAllocation { - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", - TierLowerBound = null, + WriteOffOverage = null, }; - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Tier + var model = new LicenseAllocation { - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", - TierLowerBound = null, + WriteOffOverage = null, }; model.Validate(); @@ -6183,80 +7335,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - Tier copied = new(model); + LicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class CadenceTest : TestBase -{ - [Theory] - [InlineData(Cadence.Annual)] - [InlineData(Cadence.SemiAnnual)] - [InlineData(Cadence.Monthly)] - [InlineData(Cadence.Quarterly)] - [InlineData(Cadence.OneTime)] - [InlineData(Cadence.Custom)] - public void Validation_Works(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(Cadence.Annual)] - [InlineData(Cadence.SemiAnnual)] - [InlineData(Cadence.Monthly)] - [InlineData(Cadence.Quarterly)] - [InlineData(Cadence.OneTime)] - [InlineData(Cadence.Custom)] - public void SerializationRoundtrip_Works(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] @@ -6334,19 +7425,38 @@ public void TieredSerializationRoundtripWorks() } } -public class TieredWithProrationTest : TestBase +public class TieredTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6380,14 +7490,32 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = TieredCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); string expectedName = "Annual fee"; - TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6396,7 +7524,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + TieredConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6423,9 +7551,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); + Assert.Equal(expectedTieredConfig, model.TieredConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6452,14 +7585,33 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6494,10 +7646,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); } @@ -6505,14 +7654,33 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6547,20 +7715,35 @@ 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 = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = TieredCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); string expectedName = "Annual fee"; - TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6569,7 +7752,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + TieredConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6596,9 +7779,14 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); + Assert.Equal(expectedTieredConfig, deserialized.TieredConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -6628,14 +7816,33 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6675,14 +7882,33 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, }; Assert.Null(model.BillableMetricID); @@ -6718,14 +7944,33 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, }; model.Validate(); @@ -6734,14 +7979,33 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = null, BilledInAdvance = null, @@ -6792,14 +8056,33 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = null, BilledInAdvance = null, @@ -6823,14 +8106,33 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6864,32 +8166,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - TieredWithProration copied = new(model); + Tiered copied = new(model); Assert.Equal(model, copied); } } -public class TieredWithProrationCadenceTest : TestBase +public class TieredCadenceTest : TestBase { [Theory] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Custom)] - public void Validation_Works(TieredWithProrationCadence rawValue) + [InlineData(TieredCadence.Annual)] + [InlineData(TieredCadence.SemiAnnual)] + [InlineData(TieredCadence.Monthly)] + [InlineData(TieredCadence.Quarterly)] + [InlineData(TieredCadence.OneTime)] + [InlineData(TieredCadence.Custom)] + public void Validation_Works(TieredCadence 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 ); @@ -6899,19 +8201,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) + [InlineData(TieredCadence.Annual)] + [InlineData(TieredCadence.SemiAnnual)] + [InlineData(TieredCadence.Monthly)] + [InlineData(TieredCadence.Quarterly)] + [InlineData(TieredCadence.OneTime)] + [InlineData(TieredCadence.Custom)] + public void SerializationRoundtrip_Works(TieredCadence 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 ); @@ -6922,12 +8224,12 @@ public void SerializationRoundtrip_Works(TieredWithProrationCadence 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 ); @@ -6936,38 +8238,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class TieredWithProrationConfigTest : TestBase +public class TieredLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new TieredLicenseAllocation { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new TieredLicenseAllocation { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6978,121 +8281,83 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfig + var model = new TieredLicenseAllocation { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfig + var model = new TieredLicenseAllocation { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); } [Fact] - public void CopyConstructor_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - TieredWithProrationConfig copied = new(model); + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; - Assert.Equal(model, copied); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + model.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProrationConfigTier + var model = new TieredLicenseAllocation { - 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); - } + Amount = "amount", + Currency = "currency", - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + WriteOffOverage = null, }; - 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); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProrationConfigTier + var model = new TieredLicenseAllocation { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, }; model.Validate(); @@ -7101,24 +8366,25 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new TieredWithProrationConfigTier + var model = new TieredLicenseAllocation { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - TieredWithProrationConfigTier copied = new(model); + TieredLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class TieredWithProrationConversionRateConfigTest : TestBase +public class TieredConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + TieredConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -7129,34 +8395,33 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - TieredWithProrationConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + TieredConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + TieredConversionRateConfig 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 ); @@ -7167,23 +8432,22 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + TieredConversionRateConfig 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7192,22 +8456,25 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedWithMinMaxThresholdsTest : TestBase +public class BulkTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7242,19 +8509,21 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - GroupedWithMinMaxThresholdsCadence.Annual; - 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" + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] ); + ApiEnum expectedCadence = BulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7264,7 +8533,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + BulkConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7289,12 +8558,14 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkConfig, model.BulkConfig); Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -7323,17 +8594,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7369,10 +8643,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); } @@ -7380,17 +8651,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7426,25 +8700,24 @@ 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 = - GroupedWithMinMaxThresholdsCadence.Annual; - 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" + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] ); + ApiEnum expectedCadence = BulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7454,7 +8727,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + BulkConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7479,12 +8752,14 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkConfig, deserialized.BulkConfig); Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -7516,21 +8791,24 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, @@ -7567,17 +8845,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", }; @@ -7614,17 +8895,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", }; @@ -7634,17 +8918,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = null, @@ -7696,17 +8983,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = null, @@ -7731,17 +9021,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7776,32 +9069,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - GroupedWithMinMaxThresholds copied = new(model); + Bulk copied = new(model); Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class BulkCadenceTest : TestBase { [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(GroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(BulkCadence.Annual)] + [InlineData(BulkCadence.SemiAnnual)] + [InlineData(BulkCadence.Monthly)] + [InlineData(BulkCadence.Quarterly)] + [InlineData(BulkCadence.OneTime)] + [InlineData(BulkCadence.Custom)] + public void Validation_Works(BulkCadence 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 ); @@ -7811,21 +9104,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(BulkCadence.Annual)] + [InlineData(BulkCadence.SemiAnnual)] + [InlineData(BulkCadence.Monthly)] + [InlineData(BulkCadence.Quarterly)] + [InlineData(BulkCadence.OneTime)] + [InlineData(BulkCadence.Custom)] + public void SerializationRoundtrip_Works(BulkCadence 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 - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -7833,56 +9127,53 @@ public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence rawV [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< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class GroupedWithMinMaxThresholdsConfigTest : TestBase +public class BulkLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7893,41 +9184,83 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, }; model.Validate(); @@ -7936,70 +9269,65 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - GroupedWithMinMaxThresholdsConfig copied = new(model); + BulkLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class BulkConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + BulkConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + BulkConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + BulkConversionRateConfig 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); } @@ -8007,48 +9335,57 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + BulkConversionRateConfig 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 - ); + 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 CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8083,19 +9420,27 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig expectedBulkWithFiltersConfig = 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" }, + ], }; + ApiEnum expectedCadence = BulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8105,7 +9450,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + BulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8130,12 +9475,14 @@ 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -8164,17 +9511,28 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8210,7 +9568,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8221,17 +9579,28 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8267,25 +9636,33 @@ 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 = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig expectedBulkWithFiltersConfig = 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" }, + ], }; + ApiEnum expectedCadence = BulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8295,7 +9672,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + BulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8320,12 +9697,14 @@ 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -8357,17 +9736,28 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8408,17 +9798,28 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", }; @@ -8455,17 +9856,28 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", }; @@ -8475,19 +9887,30 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - + 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.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + BillableMetricID = null, BilledInAdvance = null, BillingCycleConfiguration = null, @@ -8537,17 +9960,28 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = null, @@ -8572,17 +10006,28 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8617,32 +10062,326 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - CumulativeGroupedAllocation copied = new(model); + BulkWithFilters copied = new(model); Assert.Equal(model, copied); } } -public class CumulativeGroupedAllocationCadenceTest : TestBase +public class BulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 SerializationRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new 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 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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 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 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 Filter { PropertyKey = "x", PropertyValue = "x" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Tier { 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 Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Tier { UnitAmount = "unit_amount" }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Tier { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new 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 Tier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithFiltersCadenceTest : TestBase { [Theory] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(BulkWithFiltersCadence.Annual)] + [InlineData(BulkWithFiltersCadence.SemiAnnual)] + [InlineData(BulkWithFiltersCadence.Monthly)] + [InlineData(BulkWithFiltersCadence.Quarterly)] + [InlineData(BulkWithFiltersCadence.OneTime)] + [InlineData(BulkWithFiltersCadence.Custom)] + public void Validation_Works(BulkWithFiltersCadence 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 ); @@ -8652,21 +10391,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(BulkWithFiltersCadence.Annual)] + [InlineData(BulkWithFiltersCadence.SemiAnnual)] + [InlineData(BulkWithFiltersCadence.Monthly)] + [InlineData(BulkWithFiltersCadence.Quarterly)] + [InlineData(BulkWithFiltersCadence.OneTime)] + [InlineData(BulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works(BulkWithFiltersCadence 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 - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -8674,56 +10414,53 @@ public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawV [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< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class BulkWithFiltersLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8734,157 +10471,209 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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 expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); } [Fact] - public void CopyConstructor_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", }; - CumulativeGroupedAllocationConfig copied = new(model); - - Assert.Equal(model, copied); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } -} -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); } [Fact] - public void TieredValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void UnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - CumulativeGroupedAllocationConversionRateConfig 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 model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", - Assert.Equal(value, deserialized); + WriteOffOverage = null, + }; + + model.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void CopyConstructor_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + BulkWithFiltersLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithFiltersConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithFiltersConversionRateConfig 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); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + BulkWithFiltersConversionRateConfig 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 +public class PackageTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8918,11 +10707,24 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = PercentCadence.Annual; + ApiEnum expectedCadence = PackageCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8931,7 +10733,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + PackageConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8958,9 +10760,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPercentConfig, model.PercentConfig); + Assert.Equal(expectedPackageConfig, model.PackageConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8987,12 +10794,21 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9027,7 +10843,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); } @@ -9035,12 +10851,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9075,17 +10900,30 @@ 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 = PackageCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9094,7 +10932,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + PackageConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9121,9 +10959,14 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); + Assert.Equal(expectedPackageConfig, deserialized.PackageConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9153,12 +10996,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9198,12 +11050,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, }; Assert.Null(model.BillableMetricID); @@ -9239,12 +11100,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, }; model.Validate(); @@ -9253,12 +11123,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = null, BilledInAdvance = null, @@ -9309,12 +11188,21 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = null, BilledInAdvance = null, @@ -9338,12 +11226,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9377,32 +11274,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - Percent copied = new(model); + Package copied = new(model); Assert.Equal(model, copied); } } -public class PercentCadenceTest : TestBase +public class PackageCadenceTest : 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(PackageCadence.Annual)] + [InlineData(PackageCadence.SemiAnnual)] + [InlineData(PackageCadence.Monthly)] + [InlineData(PackageCadence.Quarterly)] + [InlineData(PackageCadence.OneTime)] + [InlineData(PackageCadence.Custom)] + public void Validation_Works(PackageCadence 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 ); @@ -9412,19 +11309,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(PackageCadence.Annual)] + [InlineData(PackageCadence.SemiAnnual)] + [InlineData(PackageCadence.Monthly)] + [InlineData(PackageCadence.Quarterly)] + [InlineData(PackageCadence.OneTime)] + [InlineData(PackageCadence.Custom)] + public void SerializationRoundtrip_Works(PackageCadence 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 ); @@ -9435,12 +11332,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 ); @@ -9449,25 +11346,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PercentConfigTest : TestBase +public class PackageLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - double expectedPercent = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9478,24 +11389,84 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; 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 expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; model.Validate(); } @@ -9503,20 +11474,25 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - PercentConfig copied = new(model); + PackageLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class PercentConversionRateConfigTest : TestBase +public class PackageConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PackageConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -9527,7 +11503,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9547,13 +11523,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PackageConversionRateConfig 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 ); @@ -9564,7 +11540,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9579,7 +11555,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9588,21 +11564,30 @@ public void TieredSerializationRoundtripWorks() } } -public class EventOutputTest : TestBase +public class MatrixTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9637,15 +11622,24 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = MatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9655,7 +11649,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + MatrixConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9681,8 +11675,13 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, model.MatrixConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -9711,16 +11710,25 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9756,10 +11764,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); } @@ -9767,16 +11772,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9812,21 +11826,27 @@ 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 = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = MatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9836,7 +11856,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + MatrixConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9862,8 +11882,13 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, deserialized.MatrixConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -9895,16 +11920,25 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9945,16 +11979,25 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", }; @@ -9991,16 +12034,25 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", }; @@ -10010,16 +12062,25 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -10071,16 +12132,25 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -10105,16 +12175,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -10149,32 +12228,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - EventOutput copied = new(model); + Matrix copied = new(model); Assert.Equal(model, copied); } } -public class EventOutputCadenceTest : TestBase +public class MatrixCadenceTest : 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) + [InlineData(MatrixCadence.Annual)] + [InlineData(MatrixCadence.SemiAnnual)] + [InlineData(MatrixCadence.Monthly)] + [InlineData(MatrixCadence.Quarterly)] + [InlineData(MatrixCadence.OneTime)] + [InlineData(MatrixCadence.Custom)] + public void Validation_Works(MatrixCadence 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 ); @@ -10184,19 +12263,19 @@ public void InvalidEnumValidationThrows_Works() } [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) + [InlineData(MatrixCadence.Annual)] + [InlineData(MatrixCadence.SemiAnnual)] + [InlineData(MatrixCadence.Monthly)] + [InlineData(MatrixCadence.Quarterly)] + [InlineData(MatrixCadence.OneTime)] + [InlineData(MatrixCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixCadence 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 ); @@ -10207,12 +12286,12 @@ public void SerializationRoundtrip_Works(EventOutputCadence 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 ); @@ -10221,39 +12300,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class EventOutputConfigTest : TestBase +public class MatrixLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10264,37 +12343,37 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; 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 expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); @@ -10303,18 +12382,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new MatrixLicenseAllocation { Amount = "amount", Currency = "currency" }; - 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.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new MatrixLicenseAllocation { Amount = "amount", Currency = "currency" }; model.Validate(); } @@ -10322,29 +12399,27 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", + Amount = "amount", + Currency = "currency", - DefaultUnitRate = null, - GroupingKey = null, + WriteOffOverage = 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.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", + Amount = "amount", + Currency = "currency", - DefaultUnitRate = null, - GroupingKey = null, + WriteOffOverage = null, }; model.Validate(); @@ -10353,25 +12428,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - EventOutputConfig copied = new(model); + MatrixLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class EventOutputConversionRateConfigTest : TestBase +public class MatrixConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MatrixConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -10382,7 +12457,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + MatrixConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -10402,13 +12477,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MatrixConversionRateConfig 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 ); @@ -10419,7 +12494,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + MatrixConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -10434,7 +12509,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10443,27 +12518,217 @@ public void TieredSerializationRoundtripWorks() } } -public class RemoveAdjustmentTest : TestBase +public class ThresholdTotalAmountTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; + ApiEnum expectedCadence = + ThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, model.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ); @@ -10474,26 +12739,219 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; + ApiEnum expectedCadence = + ThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, deserialized.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; model.Validate(); } @@ -10501,16 +12959,88 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 RemoveAdjustment { AdjustmentID = "adjustment_id" }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; model.Validate(); } @@ -10518,25 +13048,117 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new RemoveAdjustment + var model = new ThresholdTotalAmount { - AdjustmentID = "adjustment_id", + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, - PlanPhaseOrder = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 RemoveAdjustment + var model = new ThresholdTotalAmount { - AdjustmentID = "adjustment_id", + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, - PlanPhaseOrder = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); @@ -10545,35 +13167,167 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; - RemoveAdjustment copied = new(model); + ThresholdTotalAmount copied = new(model); Assert.Equal(model, copied); } } -public class RemovePriceTest : TestBase +public class ThresholdTotalAmountCadenceTest : TestBase +{ + [Theory] + [InlineData(ThresholdTotalAmountCadence.Annual)] + [InlineData(ThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ThresholdTotalAmountCadence.Monthly)] + [InlineData(ThresholdTotalAmountCadence.Quarterly)] + [InlineData(ThresholdTotalAmountCadence.OneTime)] + [InlineData(ThresholdTotalAmountCadence.Custom)] + public void Validation_Works(ThresholdTotalAmountCadence 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(ThresholdTotalAmountCadence.Annual)] + [InlineData(ThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ThresholdTotalAmountCadence.Monthly)] + [InlineData(ThresholdTotalAmountCadence.Quarterly)] + [InlineData(ThresholdTotalAmountCadence.OneTime)] + [InlineData(ThresholdTotalAmountCadence.Custom)] + public void SerializationRoundtrip_Works(ThresholdTotalAmountCadence 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 ThresholdTotalAmountLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10584,26 +13338,38 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } @@ -10611,16 +13377,24 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new RemovePrice { PriceID = "price_id" }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new RemovePrice { PriceID = "price_id" }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; model.Validate(); } @@ -10628,25 +13402,27 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new RemovePrice + var model = new ThresholdTotalAmountLicenseAllocation { - PriceID = "price_id", + Amount = "amount", + Currency = "currency", - PlanPhaseOrder = null, + WriteOffOverage = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new RemovePrice + var model = new ThresholdTotalAmountLicenseAllocation { - PriceID = "price_id", + Amount = "amount", + Currency = "currency", - PlanPhaseOrder = null, + WriteOffOverage = null, }; model.Validate(); @@ -10655,104 +13431,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - RemovePrice copied = new(model); + ThresholdTotalAmountLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class ReplaceAdjustmentTest : TestBase +public class ThresholdTotalAmountConfigTest : TestBase { [Fact] public void FieldRoundtrip_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 = 0, - }; - - ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() + var model = new ThresholdTotalAmountConfig { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + ConsumptionTable = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Prorate = true, }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; + + Assert.Equal(expectedConsumptionTable.Count, model.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], model.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, model.Prorate); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10763,94 +13499,49 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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, - }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedConsumptionTable.Count, deserialized.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], deserialized.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, deserialized.Prorate); } [Fact] public void Validation_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; model.Validate(); @@ -10859,61 +13550,29 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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", + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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", + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], }; model.Validate(); @@ -10922,65 +13581,33 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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", + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], - PlanPhaseOrder = null, + Prorate = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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", + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], - PlanPhaseOrder = null, + Prorate = null, }; model.Validate(); @@ -10989,228 +13616,134 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; - ReplaceAdjustment copied = new(model); + ThresholdTotalAmountConfig copied = new(model); Assert.Equal(model, copied); } } -public class ReplaceAdjustmentAdjustmentTest : TestBase +public class ConsumptionTableTest : TestBase { [Fact] - public void NewPercentageDiscountValidationWorks() + public void FieldRoundtrip_Works() { - ReplaceAdjustmentAdjustment value = 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, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, model.Threshold); + Assert.Equal(expectedTotalAmount, model.TotalAmount); } [Fact] - public void NewUsageDiscountValidationWorks() + public void SerializationRoundtrip_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() - { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewUsageDiscountFilterField.PriceID, - Operator = Models::NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewUsageDiscountPriceType.Usage, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewAmountDiscountValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() - { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.Usage, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, deserialized.Threshold); + Assert.Equal(expectedTotalAmount, deserialized.TotalAmount); } [Fact] - public void NewMinimumValidationWorks() + public void Validation_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() - { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.Usage, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + model.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void CopyConstructor_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() - { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMaximumFilterField.PriceID, - Operator = Models::NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMaximumPriceType.Usage, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + ConsumptionTable copied = new(model); + + Assert.Equal(model, copied); } +} +public class ThresholdTotalAmountConversionRateConfigTest : TestBase +{ [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void UnitValidationWorks() { - ReplaceAdjustmentAdjustment value = 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 element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } - Assert.Equal(value, deserialized); + [Fact] + public void TieredValidationWorks() + { + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() - { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewUsageDiscountFilterField.PriceID, - Operator = Models::NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewUsageDiscountPriceType.Usage, - }; + ThresholdTotalAmountConversionRateConfig 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 ); @@ -11219,211 +13752,61 @@ public void NewUsageDiscountSerializationRoundtripWorks() } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() - { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.Usage, - }; + ThresholdTotalAmountConversionRateConfig 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } +} +public class TieredPackageTest : TestBase +{ [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + var model = new TieredPackage { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = TieredPackageCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + LicenseAllocations = [ new() { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewMaximumSerializationRoundtripWorks() - { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() - { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMaximumFilterField.PriceID, - Operator = Models::NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 FieldRoundtrip_Works() - { - var model = new ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Name = "Annual fee", + TieredPackageConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - LicenseTypeID = "license_type_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, - }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - }; - - string expectedReplacesPriceID = "replaces_price_id"; - Models::NewAllocationPrice expectedAllocationPrice = 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", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - long expectedPlanPhaseOrder = 0; - ReplacePricePrice expectedPrice = 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() @@ -11457,87 +13840,155 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); + ApiEnum expectedCadence = TieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + TieredPackageConfig expectedTieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageConfig, model.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePrice + var model = new TieredPackage { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ExpiresAtEndOfCadence = true, - Filters = + ], + Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - 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, - }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }, + LicenseTypeID = "license_type_id", + 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 ); @@ -11548,116 +13999,29 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePrice - { - 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", - LicenseTypeID = "license_type_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, - }, - LicenseTypeID = "license_type_id", - 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 expectedReplacesPriceID = "replaces_price_id"; - Models::NewAllocationPrice expectedAllocationPrice = new() + var model = new TieredPackage { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, ], - ItemID = "item_id", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - long expectedPlanPhaseOrder = 0; - ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() - { - Cadence = Models::NewPlanUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -11691,83 +14055,161 @@ public void FieldRoundtripThroughSerialization_Works() ReferenceID = "reference_id", }; - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); - } + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - [Fact] - public void Validation_Works() - { - var model = new ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + ApiEnum expectedCadence = TieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + 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", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + TieredPackageConfig expectedTieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() { - 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() + 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredPackageConfig, deserialized.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; model.Validate(); @@ -11776,20 +14218,88 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + var model = new TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - 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.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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + var model = new TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; model.Validate(); } @@ -11797,33 +14307,117 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePrice + var model = new TieredPackage { - ReplacesPriceID = "replaces_price_id", + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - 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.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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePrice + var model = new TieredPackage { - ReplacesPriceID = "replaces_price_id", + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); @@ -11832,82 +14426,79871 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new ReplacePrice + var model = new TieredPackage { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ExpiresAtEndOfCadence = true, - Filters = + ], + Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - 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, - }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - ReplacePrice copied = new(model); + TieredPackage copied = new(model); Assert.Equal(model, copied); } } +public class TieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredPackageCadence.Annual)] + [InlineData(TieredPackageCadence.SemiAnnual)] + [InlineData(TieredPackageCadence.Monthly)] + [InlineData(TieredPackageCadence.Quarterly)] + [InlineData(TieredPackageCadence.OneTime)] + [InlineData(TieredPackageCadence.Custom)] + public void Validation_Works(TieredPackageCadence 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(TieredPackageCadence.Annual)] + [InlineData(TieredPackageCadence.SemiAnnual)] + [InlineData(TieredPackageCadence.Monthly)] + [InlineData(TieredPackageCadence.Quarterly)] + [InlineData(TieredPackageCadence.OneTime)] + [InlineData(TieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(TieredPackageCadence 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 TieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredPackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + TieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + 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 TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredPackageConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredPackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredPackageConversionRateConfig 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() + { + TieredPackageConversionRateConfig 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 TieredWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = TieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + TieredWithMinimumConfig expectedTieredWithMinimumConfig = 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithMinimumConfig, model.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = TieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + TieredWithMinimumConfig expectedTieredWithMinimumConfig = 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithMinimumConfig, deserialized.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredWithMinimumCadence.Annual)] + [InlineData(TieredWithMinimumCadence.SemiAnnual)] + [InlineData(TieredWithMinimumCadence.Monthly)] + [InlineData(TieredWithMinimumCadence.Quarterly)] + [InlineData(TieredWithMinimumCadence.OneTime)] + [InlineData(TieredWithMinimumCadence.Custom)] + public void Validation_Works(TieredWithMinimumCadence 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(TieredWithMinimumCadence.Annual)] + [InlineData(TieredWithMinimumCadence.SemiAnnual)] + [InlineData(TieredWithMinimumCadence.Monthly)] + [InlineData(TieredWithMinimumCadence.Quarterly)] + [InlineData(TieredWithMinimumCadence.OneTime)] + [InlineData(TieredWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(TieredWithMinimumCadence 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 TieredWithMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, model.HideZeroAmountTiers); + Assert.Equal(expectedProrate, model.Prorate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + 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 TieredWithMinimumConfig + { + 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, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, deserialized.HideZeroAmountTiers); + Assert.Equal(expectedProrate, deserialized.Prorate); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + TieredWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredWithMinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredWithMinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredWithMinimumConversionRateConfig 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() + { + TieredWithMinimumConversionRateConfig 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 GroupedTieredTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = GroupedTieredCadence.Annual; + GroupedTieredConfig expectedGroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + GroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredConfig, model.GroupedTieredConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = GroupedTieredCadence.Annual; + GroupedTieredConfig expectedGroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + GroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredConfig, deserialized.GroupedTieredConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedTiered copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedTieredCadence.Annual)] + [InlineData(GroupedTieredCadence.SemiAnnual)] + [InlineData(GroupedTieredCadence.Monthly)] + [InlineData(GroupedTieredCadence.Quarterly)] + [InlineData(GroupedTieredCadence.OneTime)] + [InlineData(GroupedTieredCadence.Custom)] + public void Validation_Works(GroupedTieredCadence 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(GroupedTieredCadence.Annual)] + [InlineData(GroupedTieredCadence.SemiAnnual)] + [InlineData(GroupedTieredCadence.Monthly)] + [InlineData(GroupedTieredCadence.Quarterly)] + [InlineData(GroupedTieredCadence.OneTime)] + [InlineData(GroupedTieredCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedTieredCadence 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 GroupedTieredConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + GroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + GroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedTieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedTieredLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedTieredConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedTieredConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedTieredConversionRateConfig 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() + { + GroupedTieredConversionRateConfig 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 TieredPackageWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + TieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + TieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageWithMinimumConfig, model.TieredPackageWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + TieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + TieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedTieredPackageWithMinimumConfig, + deserialized.TieredPackageWithMinimumConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredPackageWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredPackageWithMinimumCadence.Annual)] + [InlineData(TieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(TieredPackageWithMinimumCadence.Monthly)] + [InlineData(TieredPackageWithMinimumCadence.Quarterly)] + [InlineData(TieredPackageWithMinimumCadence.OneTime)] + [InlineData(TieredPackageWithMinimumCadence.Custom)] + public void Validation_Works(TieredPackageWithMinimumCadence 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(TieredPackageWithMinimumCadence.Annual)] + [InlineData(TieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(TieredPackageWithMinimumCadence.Monthly)] + [InlineData(TieredPackageWithMinimumCadence.Quarterly)] + [InlineData(TieredPackageWithMinimumCadence.OneTime)] + [InlineData(TieredPackageWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(TieredPackageWithMinimumCadence 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 TieredPackageWithMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredPackageWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + TieredPackageWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + 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 TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredPackageWithMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredPackageWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredPackageWithMinimumConversionRateConfig 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() + { + TieredPackageWithMinimumConversionRateConfig 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 PackageWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + PackageWithAllocationConfig expectedPackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPackageWithAllocationConfig, model.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + PackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + PackageWithAllocationConfig expectedPackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPackageWithAllocationConfig, deserialized.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(PackageWithAllocationCadence.Annual)] + [InlineData(PackageWithAllocationCadence.SemiAnnual)] + [InlineData(PackageWithAllocationCadence.Monthly)] + [InlineData(PackageWithAllocationCadence.Quarterly)] + [InlineData(PackageWithAllocationCadence.OneTime)] + [InlineData(PackageWithAllocationCadence.Custom)] + public void Validation_Works(PackageWithAllocationCadence 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(PackageWithAllocationCadence.Annual)] + [InlineData(PackageWithAllocationCadence.SemiAnnual)] + [InlineData(PackageWithAllocationCadence.Monthly)] + [InlineData(PackageWithAllocationCadence.Quarterly)] + [InlineData(PackageWithAllocationCadence.OneTime)] + [InlineData(PackageWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(PackageWithAllocationCadence 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 PackageWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + PackageWithAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedPackageAmount, model.PackageAmount); + Assert.Equal(expectedPackageSize, model.PackageSize); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + 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 PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedPackageAmount, deserialized.PackageAmount); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + PackageWithAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PackageWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PackageWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PackageWithAllocationConversionRateConfig 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() + { + PackageWithAllocationConversionRateConfig 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 UnitWithPercentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = UnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + UnitWithPercentConfig expectedUnitWithPercentConfig = new() + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithPercentConfig, model.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = UnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + UnitWithPercentConfig expectedUnitWithPercentConfig = new() + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithPercentConfig, deserialized.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + UnitWithPercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentCadenceTest : TestBase +{ + [Theory] + [InlineData(UnitWithPercentCadence.Annual)] + [InlineData(UnitWithPercentCadence.SemiAnnual)] + [InlineData(UnitWithPercentCadence.Monthly)] + [InlineData(UnitWithPercentCadence.Quarterly)] + [InlineData(UnitWithPercentCadence.OneTime)] + [InlineData(UnitWithPercentCadence.Custom)] + public void Validation_Works(UnitWithPercentCadence 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(UnitWithPercentCadence.Annual)] + [InlineData(UnitWithPercentCadence.SemiAnnual)] + [InlineData(UnitWithPercentCadence.Monthly)] + [InlineData(UnitWithPercentCadence.Quarterly)] + [InlineData(UnitWithPercentCadence.OneTime)] + [InlineData(UnitWithPercentCadence.Custom)] + public void SerializationRoundtrip_Works(UnitWithPercentCadence 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 UnitWithPercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + UnitWithPercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", 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 UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + UnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + UnitWithPercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + UnitWithPercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + UnitWithPercentConversionRateConfig 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() + { + UnitWithPercentConversionRateConfig 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 MatrixWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + MatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, model.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + MatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, deserialized.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MatrixWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithAllocationCadence.Annual)] + [InlineData(MatrixWithAllocationCadence.SemiAnnual)] + [InlineData(MatrixWithAllocationCadence.Monthly)] + [InlineData(MatrixWithAllocationCadence.Quarterly)] + [InlineData(MatrixWithAllocationCadence.OneTime)] + [InlineData(MatrixWithAllocationCadence.Custom)] + public void Validation_Works(MatrixWithAllocationCadence 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(MatrixWithAllocationCadence.Annual)] + [InlineData(MatrixWithAllocationCadence.SemiAnnual)] + [InlineData(MatrixWithAllocationCadence.Monthly)] + [InlineData(MatrixWithAllocationCadence.Quarterly)] + [InlineData(MatrixWithAllocationCadence.OneTime)] + [InlineData(MatrixWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithAllocationCadence 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 MatrixWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MatrixWithAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithAllocationConversionRateConfig 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() + { + MatrixWithAllocationConversionRateConfig 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 TieredWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + TieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + TieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredWithProrationCadence.Annual)] + [InlineData(TieredWithProrationCadence.SemiAnnual)] + [InlineData(TieredWithProrationCadence.Monthly)] + [InlineData(TieredWithProrationCadence.Quarterly)] + [InlineData(TieredWithProrationCadence.OneTime)] + [InlineData(TieredWithProrationCadence.Custom)] + public void Validation_Works(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>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(TieredWithProrationCadence.Annual)] + [InlineData(TieredWithProrationCadence.SemiAnnual)] + [InlineData(TieredWithProrationCadence.Monthly)] + [InlineData(TieredWithProrationCadence.Quarterly)] + [InlineData(TieredWithProrationCadence.OneTime)] + [InlineData(TieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(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>( + 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 TieredWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 TieredWithProrationConfig + { + 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 TieredWithProrationConfig + { + 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 TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredWithProrationConversionRateConfig 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() + { + TieredWithProrationConversionRateConfig 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 UnitWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = UnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + UnitWithProrationConfig expectedUnitWithProrationConfig = new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 = UnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + UnitWithProrationConfig expectedUnitWithProrationConfig = new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithProrationConfig, deserialized.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + UnitWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(UnitWithProrationCadence.Annual)] + [InlineData(UnitWithProrationCadence.SemiAnnual)] + [InlineData(UnitWithProrationCadence.Monthly)] + [InlineData(UnitWithProrationCadence.Quarterly)] + [InlineData(UnitWithProrationCadence.OneTime)] + [InlineData(UnitWithProrationCadence.Custom)] + public void Validation_Works(UnitWithProrationCadence 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(UnitWithProrationCadence.Annual)] + [InlineData(UnitWithProrationCadence.SemiAnnual)] + [InlineData(UnitWithProrationCadence.Monthly)] + [InlineData(UnitWithProrationCadence.Quarterly)] + [InlineData(UnitWithProrationCadence.OneTime)] + [InlineData(UnitWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(UnitWithProrationCadence 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 UnitWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + UnitWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationConfig { 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 UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + UnitWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + UnitWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + UnitWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + UnitWithProrationConversionRateConfig 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() + { + UnitWithProrationConversionRateConfig 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 GroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = GroupedAllocationCadence.Annual; + GroupedAllocationConfig expectedGroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + GroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, model.GroupedAllocationConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = GroupedAllocationCadence.Annual; + GroupedAllocationConfig expectedGroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + GroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, deserialized.GroupedAllocationConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedAllocationCadence.Annual)] + [InlineData(GroupedAllocationCadence.SemiAnnual)] + [InlineData(GroupedAllocationCadence.Monthly)] + [InlineData(GroupedAllocationCadence.Quarterly)] + [InlineData(GroupedAllocationCadence.OneTime)] + [InlineData(GroupedAllocationCadence.Custom)] + public void Validation_Works(GroupedAllocationCadence 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(GroupedAllocationCadence.Annual)] + [InlineData(GroupedAllocationCadence.SemiAnnual)] + [InlineData(GroupedAllocationCadence.Monthly)] + [InlineData(GroupedAllocationCadence.Quarterly)] + [InlineData(GroupedAllocationCadence.OneTime)] + [InlineData(GroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedAllocationCadence 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 GroupedAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedOverageUnitRate, model.OverageUnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_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 GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedOverageUnitRate, deserialized.OverageUnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + GroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedAllocationConversionRateConfig 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() + { + GroupedAllocationConversionRateConfig 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 BulkWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + BulkWithProrationConfig expectedBulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum expectedCadence = BulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + BulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, model.BulkWithProrationConfig); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + BulkWithProrationConfig expectedBulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum expectedCadence = BulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + BulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, deserialized.BulkWithProrationConfig); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + BulkWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithProrationConfig + { + 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 BulkWithProrationConfig + { + 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 expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + BulkWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(BulkWithProrationCadence.Annual)] + [InlineData(BulkWithProrationCadence.SemiAnnual)] + [InlineData(BulkWithProrationCadence.Monthly)] + [InlineData(BulkWithProrationCadence.Quarterly)] + [InlineData(BulkWithProrationCadence.OneTime)] + [InlineData(BulkWithProrationCadence.Custom)] + public void Validation_Works(BulkWithProrationCadence 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(BulkWithProrationCadence.Annual)] + [InlineData(BulkWithProrationCadence.SemiAnnual)] + [InlineData(BulkWithProrationCadence.Monthly)] + [InlineData(BulkWithProrationCadence.Quarterly)] + [InlineData(BulkWithProrationCadence.OneTime)] + [InlineData(BulkWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(BulkWithProrationCadence 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 BulkWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + BulkWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + BulkWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithProrationConversionRateConfig 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() + { + BulkWithProrationConversionRateConfig 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 GroupedWithProratedMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithProratedMinimumCadence.Annual; + GroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + GroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + model.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithProratedMinimumCadence.Annual; + GroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + GroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + deserialized.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithProratedMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithProratedMinimumCadence.Annual)] + [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithProratedMinimumCadence.Monthly)] + [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(GroupedWithProratedMinimumCadence.OneTime)] + [InlineData(GroupedWithProratedMinimumCadence.Custom)] + public void Validation_Works(GroupedWithProratedMinimumCadence 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(GroupedWithProratedMinimumCadence.Annual)] + [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithProratedMinimumCadence.Monthly)] + [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(GroupedWithProratedMinimumCadence.OneTime)] + [InlineData(GroupedWithProratedMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithProratedMinimumCadence 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 GroupedWithProratedMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimum, model.Minimum); + Assert.Equal(expectedUnitRate, model.UnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "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 GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimum, deserialized.Minimum); + Assert.Equal(expectedUnitRate, deserialized.UnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + GroupedWithProratedMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithProratedMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithProratedMinimumConversionRateConfig 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() + { + GroupedWithProratedMinimumConversionRateConfig 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 GroupedWithMeteredMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithMeteredMinimumCadence.Annual; + GroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + GroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + model.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithMeteredMinimumCadence.Annual; + GroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + GroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + deserialized.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithMeteredMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMeteredMinimumCadence.Annual)] + [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(GroupedWithMeteredMinimumCadence.Custom)] + public void Validation_Works(GroupedWithMeteredMinimumCadence 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(GroupedWithMeteredMinimumCadence.Annual)] + [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(GroupedWithMeteredMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumCadence 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 GroupedWithMeteredMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, model.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, model.PricingKey); + Assert.Equal(expectedScalingFactors.Count, model.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], model.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, model.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + 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 GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, deserialized.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, deserialized.PricingKey); + Assert.Equal(expectedScalingFactors.Count, deserialized.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], deserialized.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, deserialized.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + GroupedWithMeteredMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string expectedScalingFactorValue = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactorValue, model.ScalingFactorValue); + Assert.Equal(expectedScalingValue, model.ScalingValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + 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 ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedScalingFactorValue = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactorValue, deserialized.ScalingFactorValue); + Assert.Equal(expectedScalingValue, deserialized.ScalingValue); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + ScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmountValue = "unit_amount"; + + Assert.Equal(expectedPricingValue, model.PricingValue); + Assert.Equal(expectedUnitAmountValue, model.UnitAmountValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "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 UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmountValue = "unit_amount"; + + Assert.Equal(expectedPricingValue, deserialized.PricingValue); + Assert.Equal(expectedUnitAmountValue, deserialized.UnitAmountValue); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + UnitAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithMeteredMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithMeteredMinimumConversionRateConfig 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() + { + GroupedWithMeteredMinimumConversionRateConfig 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 GroupedWithMinMaxThresholdsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithMinMaxThresholdsCadence.Annual; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + GroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithMinMaxThresholdsCadence.Annual; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + GroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(GroupedWithMinMaxThresholdsCadence 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(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence 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 GroupedWithMinMaxThresholdsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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() + { + var model = new 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 + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new 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 + ); + 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 GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithMinMaxThresholdsLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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 MatrixWithDisplayNameTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + MatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, model.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + MatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, deserialized.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MatrixWithDisplayName copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithDisplayNameCadence.Annual)] + [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(MatrixWithDisplayNameCadence.Monthly)] + [InlineData(MatrixWithDisplayNameCadence.Quarterly)] + [InlineData(MatrixWithDisplayNameCadence.OneTime)] + [InlineData(MatrixWithDisplayNameCadence.Custom)] + public void Validation_Works(MatrixWithDisplayNameCadence 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(MatrixWithDisplayNameCadence.Annual)] + [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(MatrixWithDisplayNameCadence.Monthly)] + [InlineData(MatrixWithDisplayNameCadence.Quarterly)] + [InlineData(MatrixWithDisplayNameCadence.OneTime)] + [InlineData(MatrixWithDisplayNameCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithDisplayNameCadence 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 MatrixWithDisplayNameLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MatrixWithDisplayNameLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, model.Dimension); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, deserialized.Dimension); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + MatrixWithDisplayNameConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConfigUnitAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, model.DimensionValue); + Assert.Equal(expectedDisplayName, model.DisplayName); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, deserialized.DimensionValue); + Assert.Equal(expectedDisplayName, deserialized.DisplayName); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + MatrixWithDisplayNameConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithDisplayNameConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithDisplayNameConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithDisplayNameConversionRateConfig 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() + { + MatrixWithDisplayNameConversionRateConfig 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 GroupedTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedTieredPackageCadence.Annual; + GroupedTieredPackageConfig expectedGroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + GroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, model.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedTieredPackageCadence.Annual; + GroupedTieredPackageConfig expectedGroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + GroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, deserialized.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedTieredPackageCadence.Annual)] + [InlineData(GroupedTieredPackageCadence.SemiAnnual)] + [InlineData(GroupedTieredPackageCadence.Monthly)] + [InlineData(GroupedTieredPackageCadence.Quarterly)] + [InlineData(GroupedTieredPackageCadence.OneTime)] + [InlineData(GroupedTieredPackageCadence.Custom)] + public void Validation_Works(GroupedTieredPackageCadence 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(GroupedTieredPackageCadence.Annual)] + [InlineData(GroupedTieredPackageCadence.SemiAnnual)] + [InlineData(GroupedTieredPackageCadence.Monthly)] + [InlineData(GroupedTieredPackageCadence.Quarterly)] + [InlineData(GroupedTieredPackageCadence.OneTime)] + [InlineData(GroupedTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedTieredPackageCadence 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 GroupedTieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + GroupedTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + 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 GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + GroupedTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedTieredPackageConversionRateConfig 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() + { + GroupedTieredPackageConversionRateConfig 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 MaxGroupTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + MaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, model.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + MaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, deserialized.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MaxGroupTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(MaxGroupTieredPackageCadence.Annual)] + [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(MaxGroupTieredPackageCadence.Monthly)] + [InlineData(MaxGroupTieredPackageCadence.Quarterly)] + [InlineData(MaxGroupTieredPackageCadence.OneTime)] + [InlineData(MaxGroupTieredPackageCadence.Custom)] + public void Validation_Works(MaxGroupTieredPackageCadence 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(MaxGroupTieredPackageCadence.Annual)] + [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(MaxGroupTieredPackageCadence.Monthly)] + [InlineData(MaxGroupTieredPackageCadence.Quarterly)] + [InlineData(MaxGroupTieredPackageCadence.OneTime)] + [InlineData(MaxGroupTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(MaxGroupTieredPackageCadence 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 MaxGroupTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MaxGroupTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + MaxGroupTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + MaxGroupTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MaxGroupTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MaxGroupTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MaxGroupTieredPackageConversionRateConfig 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() + { + MaxGroupTieredPackageConversionRateConfig 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 ScalableMatrixWithUnitPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + model.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + deserialized.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] + public void Validation_Works(ScalableMatrixWithUnitPricingCadence 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(ScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] + public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingCadence 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 ScalableMatrixWithUnitPricingLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ScalableMatrixWithUnitPricingLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedProrate, model.Prorate); + Assert.Equal(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + 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 ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedProrate, deserialized.Prorate); + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + MatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig 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() + { + ScalableMatrixWithUnitPricingConversionRateConfig 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 ScalableMatrixWithTieredPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + model.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + deserialized.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] + public void Validation_Works(ScalableMatrixWithTieredPricingCadence 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(ScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] + public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingCadence 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 ScalableMatrixWithTieredPricingLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ScalableMatrixWithTieredPricingLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[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(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + 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 ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[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(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + ScalableMatrixWithTieredPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ScalableMatrixWithTieredPricingConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig 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() + { + ScalableMatrixWithTieredPricingConversionRateConfig 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 CumulativeGroupedBulkTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + CumulativeGroupedBulkCadence.Annual; + CumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + CumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, model.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + CumulativeGroupedBulkCadence.Annual; + CumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + CumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, deserialized.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + CumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkCadenceTest : TestBase +{ + [Theory] + [InlineData(CumulativeGroupedBulkCadence.Annual)] + [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(CumulativeGroupedBulkCadence.Monthly)] + [InlineData(CumulativeGroupedBulkCadence.Quarterly)] + [InlineData(CumulativeGroupedBulkCadence.OneTime)] + [InlineData(CumulativeGroupedBulkCadence.Custom)] + public void Validation_Works(CumulativeGroupedBulkCadence 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(CumulativeGroupedBulkCadence.Annual)] + [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(CumulativeGroupedBulkCadence.Monthly)] + [InlineData(CumulativeGroupedBulkCadence.Quarterly)] + [InlineData(CumulativeGroupedBulkCadence.OneTime)] + [InlineData(CumulativeGroupedBulkCadence.Custom)] + public void SerializationRoundtrip_Works(CumulativeGroupedBulkCadence 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 CumulativeGroupedBulkConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } + Assert.Equal(expectedGroup, model.Group); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + 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 CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } + Assert.Equal(expectedGroup, deserialized.Group); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + CumulativeGroupedBulkConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DimensionValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + 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 DimensionValue + { + GroupingKey = "x", + 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 expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + DimensionValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + CumulativeGroupedBulkLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + CumulativeGroupedBulkConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + CumulativeGroupedBulkConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + CumulativeGroupedBulkConversionRateConfig 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() + { + CumulativeGroupedBulkConversionRateConfig 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 CumulativeGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + CumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + CumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [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.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + CumulativeGroupedAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + CumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + CumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + CumulativeGroupedAllocationConversionRateConfig 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() + { + CumulativeGroupedAllocationConversionRateConfig 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 MinimumCompositeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = MinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MinimumCompositeConfig expectedMinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + MinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, model.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 = MinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MinimumCompositeConfig expectedMinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + MinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, deserialized.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MinimumComposite copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeCadenceTest : TestBase +{ + [Theory] + [InlineData(MinimumCompositeCadence.Annual)] + [InlineData(MinimumCompositeCadence.SemiAnnual)] + [InlineData(MinimumCompositeCadence.Monthly)] + [InlineData(MinimumCompositeCadence.Quarterly)] + [InlineData(MinimumCompositeCadence.OneTime)] + [InlineData(MinimumCompositeCadence.Custom)] + public void Validation_Works(MinimumCompositeCadence 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(MinimumCompositeCadence.Annual)] + [InlineData(MinimumCompositeCadence.SemiAnnual)] + [InlineData(MinimumCompositeCadence.Monthly)] + [InlineData(MinimumCompositeCadence.Quarterly)] + [InlineData(MinimumCompositeCadence.OneTime)] + [InlineData(MinimumCompositeCadence.Custom)] + public void SerializationRoundtrip_Works(MinimumCompositeCadence 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 MinimumCompositeLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MinimumCompositeLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumCompositeConfig { MinimumAmount = "minimum_amount" }; + + Assert.Null(model.Prorated); + Assert.False(model.RawData.ContainsKey("prorated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new MinimumCompositeConfig { MinimumAmount = "minimum_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + + // Null should be interpreted as omitted for these properties + Prorated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + MinimumCompositeConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MinimumCompositeConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MinimumCompositeConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MinimumCompositeConversionRateConfig 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() + { + MinimumCompositeConversionRateConfig 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] + public void FieldRoundtrip_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = PercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 = PercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentCadenceTest : 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) + { + // 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(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; + + 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 PercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PercentLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PercentLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + PercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PercentConfig { Percent = 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 PercentConfig { Percent = 0 }; + + 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 Validation_Works() + { + var model = new PercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PercentConversionRateConfig 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() + { + PercentConversionRateConfig 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 EventOutputTest : 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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } +} + +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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new EventOutputConfig + { + 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 EventOutputConfig + { + 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 EventOutputConfig + { + 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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EventOutputLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new EventOutputLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new EventOutputLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + EventOutputLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + EventOutputConversionRateConfig 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() + { + EventOutputConversionRateConfig 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 PriceTest : TestBase +{ + [Fact] + public void NewPlanUnitValidationWorks() + { + Price value = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanTieredValidationWorks() + { + Price value = new Models::NewPlanTieredPrice() + { + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanBulkValidationWorks() + { + Price value = new Models::NewPlanBulkPrice() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanBulkPriceModelType.Bulk, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithFiltersValidationWorks() + { + Price value = new PriceBulkWithFilters() + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanPackageValidationWorks() + { + Price value = new Models::NewPlanPackagePrice() + { + Cadence = Models::NewPlanPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMatrixValidationWorks() + { + Price value = new Models::NewPlanMatrixPrice() + { + Cadence = Models::NewPlanMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanThresholdTotalAmountValidationWorks() + { + Price value = new Models::NewPlanThresholdTotalAmountPrice() + { + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanTieredPackageValidationWorks() + { + Price value = new Models::NewPlanTieredPackagePrice() + { + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPackagePriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanTieredWithMinimumValidationWorks() + { + Price value = new Models::NewPlanTieredWithMinimumPrice() + { + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedTieredValidationWorks() + { + Price value = new Models::NewPlanGroupedTieredPrice() + { + Cadence = Models::NewPlanGroupedTieredPriceCadence.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 = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanTieredPackageWithMinimumValidationWorks() + { + Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + { + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanTieredPackageWithMinimumPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanPackageWithAllocationValidationWorks() + { + Price value = new Models::NewPlanPackageWithAllocationPrice() + { + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackageWithAllocationPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitWithPercentValidationWorks() + { + Price value = new Models::NewPlanUnitWithPercentPrice() + { + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMatrixWithAllocationValidationWorks() + { + Price value = new Models::NewPlanMatrixWithAllocationPrice() + { + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredWithProrationValidationWorks() + { + Price value = new PriceTieredWithProration() + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitWithProrationValidationWorks() + { + Price value = new Models::NewPlanUnitWithProrationPrice() + { + Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedAllocationValidationWorks() + { + Price value = new Models::NewPlanGroupedAllocationPrice() + { + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanBulkWithProrationValidationWorks() + { + Price value = new Models::NewPlanBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedWithProratedMinimumValidationWorks() + { + Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + { + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedWithMeteredMinimumValidationWorks() + { + Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + { + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMinMaxThresholdsValidationWorks() + { + Price value = new PriceGroupedWithMinMaxThresholds() + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMatrixWithDisplayNameValidationWorks() + { + Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + { + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedTieredPackageValidationWorks() + { + Price value = new Models::NewPlanGroupedTieredPackagePrice() + { + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.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 = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMaxGroupTieredPackageValidationWorks() + { + Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + { + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.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 = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + { + Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + { + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + { + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + { + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanCumulativeGroupedBulkValidationWorks() + { + Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + { + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedAllocationValidationWorks() + { + Price value = new PriceCumulativeGroupedAllocation() + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMinimumCompositeValidationWorks() + { + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PercentValidationWorks() + { + Price value = new PricePercent() + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + Price value = new PriceEventOutput() + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitSerializationRoundtripWorks() + { + Price value = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanTieredSerializationRoundtripWorks() + { + Price value = new Models::NewPlanTieredPrice() + { + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanBulkSerializationRoundtripWorks() + { + Price value = new Models::NewPlanBulkPrice() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanBulkPriceModelType.Bulk, + 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithFiltersSerializationRoundtripWorks() + { + Price value = new PriceBulkWithFilters() + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanPackageSerializationRoundtripWorks() + { + Price value = new Models::NewPlanPackagePrice() + { + Cadence = Models::NewPlanPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanMatrixSerializationRoundtripWorks() + { + Price value = new Models::NewPlanMatrixPrice() + { + Cadence = Models::NewPlanMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + { + Price value = new Models::NewPlanThresholdTotalAmountPrice() + { + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanTieredPackageSerializationRoundtripWorks() + { + Price value = new Models::NewPlanTieredPackagePrice() + { + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPackagePriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + { + Price value = new Models::NewPlanTieredWithMinimumPrice() + { + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedTieredSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedTieredPrice() + { + Cadence = Models::NewPlanGroupedTieredPriceCadence.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 = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + { + Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + { + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanTieredPackageWithMinimumPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanPackageWithAllocationPrice() + { + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackageWithAllocationPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanUnitWithPercentSerializationRoundtripWorks() + { + Price value = new Models::NewPlanUnitWithPercentPrice() + { + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanMatrixWithAllocationPrice() + { + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProrationSerializationRoundtripWorks() + { + Price value = new PriceTieredWithProration() + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanUnitWithProrationPrice() + { + Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedAllocationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedAllocationPrice() + { + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanBulkWithProrationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + { + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + { + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + Price value = new PriceGroupedWithMinMaxThresholds() + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + { + Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + { + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedTieredPackagePrice() + { + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.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 = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + { + Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + { + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.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 = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + { + Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + { + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + { + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + { + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + { + Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + { + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + { + Price value = new PriceCumulativeGroupedAllocation() + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + 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() + { + 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + Price value = new PricePercent() + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + 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() + { + Price value = new PriceEventOutput() + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PriceBulkWithFiltersTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceBulkWithFiltersBulkWithFiltersConfig 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 = + PriceBulkWithFiltersCadence.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; + PriceBulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + 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); + + PriceBulkWithFiltersBulkWithFiltersConfig 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 = + PriceBulkWithFiltersCadence.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; + PriceBulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PriceBulkWithFiltersBulkWithFiltersConfig + { + 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + PriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + PriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + PriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceBulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceBulkWithFiltersCadence.Annual)] + [InlineData(PriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(PriceBulkWithFiltersCadence.Monthly)] + [InlineData(PriceBulkWithFiltersCadence.Quarterly)] + [InlineData(PriceBulkWithFiltersCadence.OneTime)] + [InlineData(PriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(PriceBulkWithFiltersCadence 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(PriceBulkWithFiltersCadence.Annual)] + [InlineData(PriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(PriceBulkWithFiltersCadence.Monthly)] + [InlineData(PriceBulkWithFiltersCadence.Quarterly)] + [InlineData(PriceBulkWithFiltersCadence.OneTime)] + [InlineData(PriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works(PriceBulkWithFiltersCadence 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 PriceBulkWithFiltersConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceBulkWithFiltersConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceBulkWithFiltersConversionRateConfig 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() + { + PriceBulkWithFiltersConversionRateConfig 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 PriceTieredWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + PriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceTieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + PriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + PriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceTieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceTieredWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceTieredWithProrationCadence.Annual)] + [InlineData(PriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(PriceTieredWithProrationCadence.Monthly)] + [InlineData(PriceTieredWithProrationCadence.Quarterly)] + [InlineData(PriceTieredWithProrationCadence.OneTime)] + [InlineData(PriceTieredWithProrationCadence.Custom)] + public void Validation_Works(PriceTieredWithProrationCadence 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(PriceTieredWithProrationCadence.Annual)] + [InlineData(PriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(PriceTieredWithProrationCadence.Monthly)] + [InlineData(PriceTieredWithProrationCadence.Quarterly)] + [InlineData(PriceTieredWithProrationCadence.OneTime)] + [InlineData(PriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(PriceTieredWithProrationCadence 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 PriceTieredWithProrationTieredWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceTieredWithProrationTieredWithProrationConfig + { + 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 PriceTieredWithProrationTieredWithProrationConfig + { + 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 PriceTieredWithProrationTieredWithProrationConfig + { + 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 PriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + PriceTieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + PriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceTieredWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceTieredWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceTieredWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceTieredWithProrationConversionRateConfig 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() + { + PriceTieredWithProrationConversionRateConfig 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 PriceGroupedWithMinMaxThresholdsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PriceGroupedWithMinMaxThresholdsCadence.Annual; + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + PriceGroupedWithMinMaxThresholdsCadence.Annual; + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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")); + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(PriceGroupedWithMinMaxThresholdsCadence 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(PriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works(PriceGroupedWithMinMaxThresholdsCadence 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceGroupedWithMinMaxThresholdsConversionRateConfig 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() + { + PriceGroupedWithMinMaxThresholdsConversionRateConfig 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 PriceCumulativeGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PriceCumulativeGroupedAllocationCadence.Annual; + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + PriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + 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(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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 = + PriceCumulativeGroupedAllocationCadence.Annual; + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + PriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + 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(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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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")); + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceCumulativeGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(PriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(PriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(PriceCumulativeGroupedAllocationCadence 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(PriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(PriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(PriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(PriceCumulativeGroupedAllocationCadence 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceCumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceCumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceCumulativeGroupedAllocationConversionRateConfig 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() + { + PriceCumulativeGroupedAllocationConversionRateConfig 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] + public void FieldRoundtrip_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = PricePercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + PricePercentPercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PricePercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 = PricePercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + PricePercentPercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PricePercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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(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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PricePercent + { + Cadence = PricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PricePercent + { + Cadence = PricePercentCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PricePercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePercentCadenceTest : TestBase +{ + [Theory] + [InlineData(PricePercentCadence.Annual)] + [InlineData(PricePercentCadence.SemiAnnual)] + [InlineData(PricePercentCadence.Monthly)] + [InlineData(PricePercentCadence.Quarterly)] + [InlineData(PricePercentCadence.OneTime)] + [InlineData(PricePercentCadence.Custom)] + public void Validation_Works(PricePercentCadence 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(PricePercentCadence.Annual)] + [InlineData(PricePercentCadence.SemiAnnual)] + [InlineData(PricePercentCadence.Monthly)] + [InlineData(PricePercentCadence.Quarterly)] + [InlineData(PricePercentCadence.OneTime)] + [InlineData(PricePercentCadence.Custom)] + public void SerializationRoundtrip_Works(PricePercentCadence 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 PricePercentPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PricePercentPercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PricePercentPercentConfig { Percent = 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 PricePercentPercentConfig { Percent = 0 }; + + 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 Validation_Works() + { + var model = new PricePercentPercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePercentPercentConfig { Percent = 0 }; + + PricePercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PricePercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PricePercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PricePercentConversionRateConfig 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() + { + PricePercentConversionRateConfig 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 PriceEventOutputTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = PriceEventOutputCadence.Annual; + PriceEventOutputEventOutputConfig 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; + PriceEventOutputConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 = PriceEventOutputCadence.Annual; + PriceEventOutputEventOutputConfig 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; + PriceEventOutputConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEventOutputCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceEventOutputCadence.Annual)] + [InlineData(PriceEventOutputCadence.SemiAnnual)] + [InlineData(PriceEventOutputCadence.Monthly)] + [InlineData(PriceEventOutputCadence.Quarterly)] + [InlineData(PriceEventOutputCadence.OneTime)] + [InlineData(PriceEventOutputCadence.Custom)] + public void Validation_Works(PriceEventOutputCadence 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(PriceEventOutputCadence.Annual)] + [InlineData(PriceEventOutputCadence.SemiAnnual)] + [InlineData(PriceEventOutputCadence.Monthly)] + [InlineData(PriceEventOutputCadence.Quarterly)] + [InlineData(PriceEventOutputCadence.OneTime)] + [InlineData(PriceEventOutputCadence.Custom)] + public void SerializationRoundtrip_Works(PriceEventOutputCadence 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 PriceEventOutputEventOutputConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceEventOutputEventOutputConfig + { + 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 PriceEventOutputEventOutputConfig + { + 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 PriceEventOutputEventOutputConfig + { + 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 PriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceEventOutputEventOutputConfig { 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 PriceEventOutputEventOutputConfig { UnitRatingKey = "x" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceEventOutputEventOutputConfig + { + 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 PriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + PriceEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceEventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceEventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceEventOutputConversionRateConfig 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() + { + PriceEventOutputConversionRateConfig 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 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( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAdjustmentID = "adjustment_id"; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + } + + [Fact] + public void Validation_Works() + { + var model = new RemoveAdjustment { AdjustmentID = "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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + + RemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); + } +} + +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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + + RemovePrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplaceAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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 = 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); + } + + [Fact] + public void SerializationRoundtrip_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 = 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 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( + 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, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + } + + [Fact] + public void Validation_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 = 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", + }; + + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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", + }; + + 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(); + } + + [Fact] + public void CopyConstructor_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 = 0, + }; + + ReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ + [Fact] + public void NewPercentageDiscountValidationWorks() + { + ReplaceAdjustmentAdjustment value = 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, + }; + value.Validate(); + } + + [Fact] + public void NewUsageDiscountValidationWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + { + AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewUsageDiscountFilterField.PriceID, + Operator = Models::NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewUsageDiscountPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewAmountDiscountValidationWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + { + AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = Models::AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewAmountDiscountFilterField.PriceID, + Operator = Models::NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::PriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewMinimumValidationWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + { + AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = Models::NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewMinimumFilterField.PriceID, + Operator = Models::NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewMinimumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewMaximumValidationWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + { + AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = Models::NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewMaximumFilterField.PriceID, + Operator = Models::NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewMaximumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewPercentageDiscountSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = 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 element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewUsageDiscountSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + { + AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewUsageDiscountFilterField.PriceID, + Operator = Models::NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewUsageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewAmountDiscountSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + { + AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = Models::AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewAmountDiscountFilterField.PriceID, + Operator = Models::NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::PriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewMinimumSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + { + AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = Models::NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewMinimumFilterField.PriceID, + Operator = Models::NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewMinimumPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewMaximumSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + { + AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = Models::NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewMaximumFilterField.PriceID, + Operator = Models::NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::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 FieldRoundtrip_Works() + { + var model = new ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }; + + string expectedReplacesPriceID = "replaces_price_id"; + Models::NewAllocationPrice expectedAllocationPrice = 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + ReplacePriceLicenseAllocationPrice expectedLicenseAllocationPrice = + new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + long expectedPlanPhaseOrder = 0; + ReplacePricePrice expectedPrice = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, model.LicenseAllocationPrice); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedPrice, model.Price); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 expectedReplacesPriceID = "replaces_price_id"; + Models::NewAllocationPrice expectedAllocationPrice = 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + ReplacePriceLicenseAllocationPrice expectedLicenseAllocationPrice = + new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + long expectedPlanPhaseOrder = 0; + ReplacePricePrice expectedPrice = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, deserialized.LicenseAllocationPrice); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedPrice, deserialized.Price); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.False(model.RawData.ContainsKey("license_allocation_price")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.False(model.RawData.ContainsKey("price")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, + }; + + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.True(model.RawData.ContainsKey("license_allocation_price")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.True(model.RawData.ContainsKey("price")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }; + + ReplacePrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceTiered() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceBulk() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithFiltersValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceBulkWithFilters() + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PackageValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPricePackage() + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceMatrix() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ThresholdTotalAmountValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmount() + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredPackageValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredWithMinimumValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredWithMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedTieredValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedTiered() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredPackageWithMinimumValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PackageWithAllocationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPricePackageWithAllocation() + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitWithPercentValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceUnitWithPercent() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithAllocationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMatrixWithAllocation() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredWithProrationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredWithProration() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitWithProrationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceUnitWithProration() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedAllocationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedAllocation() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithProrationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceBulkWithProration() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithProratedMinimumValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum() + { + Cadence = + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMeteredMinimumValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMinMaxThresholdsValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds() + { + Cadence = + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithDisplayNameValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedTieredPackageValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MaxGroupTieredPackageValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ScalableMatrixWithUnitPricingValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing() + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ScalableMatrixWithTieredPricingValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing() + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedBulkValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk() + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedAllocationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation() + { + Cadence = + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MinimumCompositeValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMinimumComposite() + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PercentValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPricePercent() + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceEventOutput() + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceTiered() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceBulk() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithFiltersSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceBulkWithFilters() + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPricePackage() + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceMatrix() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ThresholdTotalAmountSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmount() + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithMinimumSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredWithMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedTiered() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageWithMinimumSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageWithAllocationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPricePackageWithAllocation() + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithPercentSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceUnitWithPercent() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithAllocationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMatrixWithAllocation() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProrationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredWithProration() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithProrationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceUnitWithProration() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedAllocationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedAllocation() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithProrationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceBulkWithProration() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithProratedMinimumSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum() + { + Cadence = + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMeteredMinimumSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds() + { + Cadence = + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithDisplayNameSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredPackageSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MaxGroupTieredPackageSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithUnitPricingSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing() + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithTieredPricingSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing() + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedBulkSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk() + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation() + { + Cadence = + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MinimumCompositeSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMinimumComposite() + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPricePercent() + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceEventOutput() + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceUnitTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceUnitCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitConfig, model.UnitConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceUnitCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitConfig, deserialized.UnitConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceUnit copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceUnitCadence 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(ReplacePriceLicenseAllocationPriceUnitCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceUnitCadence 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 ReplacePriceLicenseAllocationPriceUnitLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceUnitLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceTieredCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); + string expectedName = "Annual fee"; + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredConfig, model.TieredConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceTieredCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); + string expectedName = "Annual fee"; + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredConfig, deserialized.TieredConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTiered copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceTieredCadence 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(ReplacePriceLicenseAllocationPriceTieredCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredCadence 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 ReplacePriceLicenseAllocationPriceTieredLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig 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 ReplacePriceLicenseAllocationPriceBulkTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] + ); + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceBulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); + 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; + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkConfig, model.BulkConfig); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] + ); + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceBulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); + 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; + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkConfig, deserialized.BulkConfig); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulk copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceBulkCadence 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(ReplacePriceLicenseAllocationPriceBulkCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceBulkCadence 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 ReplacePriceLicenseAllocationPriceBulkLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceBulkLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig 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 = + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig 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 = + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilterTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence 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(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig 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 ReplacePriceLicenseAllocationPricePackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPricePackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); + string expectedName = "Annual fee"; + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPackageConfig, model.PackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPricePackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); + string expectedName = "Annual fee"; + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPackageConfig, deserialized.PackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPricePackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPricePackageCadence 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(ReplacePriceLicenseAllocationPricePackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPricePackageCadence 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 ReplacePriceLicenseAllocationPricePackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPricePackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPricePackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPricePackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPricePackageConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPricePackageConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMatrixTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceMatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); + 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; + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, model.MatrixConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceMatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); + 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; + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, deserialized.MatrixConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMatrix copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceMatrixCadence 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(ReplacePriceLicenseAllocationPriceMatrixCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMatrixCadence 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 ReplacePriceLicenseAllocationPriceMatrixLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = + new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, model.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = + new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, deserialized.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceThresholdTotalAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence 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(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; + + Assert.Equal(expectedConsumptionTable.Count, model.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], model.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, model.Prorate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; + + Assert.Equal(expectedConsumptionTable.Count, deserialized.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], deserialized.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, deserialized.Prorate); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + }; + + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + + Prorate = null, + }; + + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + + Prorate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTableTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, model.Threshold); + Assert.Equal(expectedTotalAmount, model.TotalAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, deserialized.Threshold); + Assert.Equal(expectedTotalAmount, deserialized.TotalAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig expectedTieredPackageConfig = + new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageConfig, model.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig expectedTieredPackageConfig = + new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredPackageConfig, deserialized.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceTieredPackageCadence 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(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredPackageCadence 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 ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + 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 ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig expectedTieredWithMinimumConfig = + 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithMinimumConfig, model.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig expectedTieredWithMinimumConfig = + 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithMinimumConfig, deserialized.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTieredWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence 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(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, model.HideZeroAmountTiers); + Assert.Equal(expectedProrate, model.Prorate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, deserialized.HideZeroAmountTiers); + Assert.Equal(expectedProrate, deserialized.Prorate); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedTieredTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig expectedGroupedTieredConfig = + new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredConfig, model.GroupedTieredConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig expectedGroupedTieredConfig = + new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredConfig, deserialized.GroupedTieredConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedTiered copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceGroupedTieredCadence 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(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedTieredCadence 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = + 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageWithMinimumConfig, model.TieredPackageWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = + 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedTieredPackageWithMinimumConfig, + deserialized.TieredPackageWithMinimumConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence 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(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig 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 ReplacePriceLicenseAllocationPricePackageWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig expectedPackageWithAllocationConfig = + new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPackageWithAllocationConfig, model.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig expectedPackageWithAllocationConfig = + new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPackageWithAllocationConfig, deserialized.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPricePackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence 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(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence 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 ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedPackageAmount, model.PackageAmount); + Assert.Equal(expectedPackageSize, model.PackageSize); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + 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 ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedPackageAmount, deserialized.PackageAmount); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceUnitWithPercentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig expectedUnitWithPercentConfig = + new() { Percent = "percent", UnitAmount = "unit_amount" }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithPercentConfig, model.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig expectedUnitWithPercentConfig = + new() { Percent = "percent", UnitAmount = "unit_amount" }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithPercentConfig, deserialized.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceUnitWithPercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithPercentCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence 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(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence 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 ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + 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 ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, model.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, deserialized.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMatrixWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence 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(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence 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(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence 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 ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceUnitWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig expectedUnitWithProrationConfig = + new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig expectedUnitWithProrationConfig = + new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithProrationConfig, deserialized.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceUnitWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence 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(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence 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 ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig expectedGroupedAllocationConfig = + new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, model.GroupedAllocationConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig expectedGroupedAllocationConfig = + new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, deserialized.GroupedAllocationConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence 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(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence 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 ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedOverageUnitRate, model.OverageUnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_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 ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedOverageUnitRate, deserialized.OverageUnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceBulkWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig expectedBulkWithProrationConfig = + new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, model.BulkWithProrationConfig); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig expectedBulkWithProrationConfig = + new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, deserialized.BulkWithProrationConfig); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulkWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + 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 expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence 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(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence 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 ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = + new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + model.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = + new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + deserialized.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence 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(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimum, model.Minimum); + Assert.Equal(expectedUnitRate, model.UnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimum, deserialized.Minimum); + Assert.Equal(expectedUnitRate, deserialized.UnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = + 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + model.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = + 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + deserialized.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence 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(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, model.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, model.PricingKey); + Assert.Equal(expectedScalingFactors.Count, model.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], model.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, model.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, deserialized.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, deserialized.PricingKey); + Assert.Equal(expectedScalingFactors.Count, deserialized.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], deserialized.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, deserialized.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string expectedScalingFactor = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedScalingValue, model.ScalingValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedScalingFactor = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedScalingValue, deserialized.ScalingValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPricingValue, model.PricingValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPricingValue, deserialized.PricingValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > 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(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = + new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, model.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = + new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, deserialized.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence 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(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, model.Dimension); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, deserialized.Dimension); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, model.DimensionValue); + Assert.Equal(expectedDisplayName, model.DisplayName); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, deserialized.DimensionValue); + Assert.Equal(expectedDisplayName, deserialized.DisplayName); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig expectedGroupedTieredPackageConfig = + new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, model.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig expectedGroupedTieredPackageConfig = + new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, deserialized.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence 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(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = + new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, model.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = + new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, deserialized.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence 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(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = + new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + model.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = + new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + deserialized.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > 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(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedProrate, model.Prorate); + Assert.Equal(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedProrate, deserialized.Prorate); + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = + 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + model.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = + 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + deserialized.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.SemiAnnual + )] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.SemiAnnual + )] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[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(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[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(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual; + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = + new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, model.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual; + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = + new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, deserialized.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence 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(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } + Assert.Equal(expectedGroup, model.Group); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } + Assert.Equal(expectedGroup, deserialized.Group); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + 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 expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual; + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual; + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > 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(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMinimumCompositeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig expectedMinimumCompositeConfig = + new() { MinimumAmount = "minimum_amount", Prorated = true }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, model.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig expectedMinimumCompositeConfig = + new() { MinimumAmount = "minimum_amount", Prorated = true }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, deserialized.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMinimumComposite copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMinimumCompositeCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence 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(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence 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 ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + }; + + Assert.Null(model.Prorated); + Assert.False(model.RawData.ContainsKey("prorated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + + // Null should be interpreted as omitted for these properties + Prorated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig 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 ReplacePriceLicenseAllocationPricePercentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPricePercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPricePercentPercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPricePercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPricePercentPercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPricePercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePercentCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPricePercentCadence 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(ReplacePriceLicenseAllocationPricePercentCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPricePercentCadence 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 ReplacePriceLicenseAllocationPricePercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPricePercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePercentPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 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 ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 0 }; + + 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 Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 0 }; + + ReplacePriceLicenseAllocationPricePercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPricePercentConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPricePercentConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPricePercentConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPricePercentConversionRateConfig 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 ReplacePriceLicenseAllocationPriceEventOutputTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual; + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual; + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceEventOutputCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceEventOutputCadence 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(ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceEventOutputCadence 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig 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 ReplacePricePriceTest : TestBase { [Fact] diff --git a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs index 0123694ae..d42fae976 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs @@ -73,6 +73,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -176,6 +224,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -279,6 +375,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -387,6 +531,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -611,6 +803,54 @@ public void CopyConstructor_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -714,6 +954,54 @@ public void CopyConstructor_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1437,12 +1725,60 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + LicenseAllocationPrice = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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", @@ -1504,6 +1840,53 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; long expectedPlanPhaseOrder = 0; Price expectedPrice = new Models::NewPlanUnitPrice() { @@ -1546,6 +1929,7 @@ public void FieldRoundtrip_Works() }; Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, model.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPrice, model.Price); } @@ -1579,6 +1963,54 @@ public void SerializationRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1657,6 +2089,54 @@ public void FieldRoundtripThroughSerialization_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1731,6 +2211,53 @@ public void FieldRoundtripThroughSerialization_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; long expectedPlanPhaseOrder = 0; Price expectedPrice = new Models::NewPlanUnitPrice() { @@ -1773,6 +2300,7 @@ public void FieldRoundtripThroughSerialization_Works() }; Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, deserialized.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPrice, deserialized.Price); } @@ -1806,6 +2334,54 @@ public void Validation_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1859,6 +2435,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.AllocationPrice); Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.False(model.RawData.ContainsKey("license_allocation_price")); Assert.Null(model.PlanPhaseOrder); Assert.False(model.RawData.ContainsKey("plan_phase_order")); Assert.Null(model.Price); @@ -1879,12 +2457,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new AddPrice { AllocationPrice = null, + LicenseAllocationPrice = null, PlanPhaseOrder = null, Price = null, }; Assert.Null(model.AllocationPrice); Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.True(model.RawData.ContainsKey("license_allocation_price")); Assert.Null(model.PlanPhaseOrder); Assert.True(model.RawData.ContainsKey("plan_phase_order")); Assert.Null(model.Price); @@ -1897,6 +2478,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new AddPrice { AllocationPrice = null, + LicenseAllocationPrice = null, PlanPhaseOrder = null, Price = null, }; @@ -1933,6 +2515,54 @@ public void CopyConstructor_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1982,16 +2612,24 @@ public void CopyConstructor_Works() } } -public class PriceTest : TestBase +public class LicenseAllocationPriceTest : TestBase { [Fact] - public void NewPlanUnitValidationWorks() + public void UnitValidationWorks() { - Price value = new Models::NewPlanUnitPrice() + LicenseAllocationPrice value = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", @@ -2030,13 +2668,21 @@ public void NewPlanUnitValidationWorks() } [Fact] - public void NewPlanTieredValidationWorks() + public void TieredValidationWorks() { - Price value = new Models::NewPlanTieredPrice() + LicenseAllocationPrice value = new Tiered() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredConfig = new() { @@ -2087,14 +2733,22 @@ public void NewPlanTieredValidationWorks() } [Fact] - public void NewPlanBulkValidationWorks() + public void BulkValidationWorks() { - Price value = new Models::NewPlanBulkPrice() + LicenseAllocationPrice value = new Bulk() { BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = BulkCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2134,7 +2788,7 @@ public void NewPlanBulkValidationWorks() [Fact] public void BulkWithFiltersValidationWorks() { - Price value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -2145,8 +2799,17 @@ public void BulkWithFiltersValidationWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2184,13 +2847,21 @@ public void BulkWithFiltersValidationWorks() } [Fact] - public void NewPlanPackageValidationWorks() + public void PackageValidationWorks() { - Price value = new Models::NewPlanPackagePrice() + LicenseAllocationPrice value = new Package() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", @@ -2229,19 +2900,27 @@ public void NewPlanPackageValidationWorks() } [Fact] - public void NewPlanMatrixValidationWorks() + public void MatrixValidationWorks() { - Price value = new Models::NewPlanMatrixPrice() + LicenseAllocationPrice value = new Matrix() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = MatrixCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixConfig = new() { DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2279,13 +2958,21 @@ public void NewPlanMatrixValidationWorks() } [Fact] - public void NewPlanThresholdTotalAmountValidationWorks() + public void ThresholdTotalAmountValidationWorks() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + LicenseAllocationPrice value = new ThresholdTotalAmount() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = ThresholdTotalAmountCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ThresholdTotalAmountConfig = new() { @@ -2332,13 +3019,21 @@ public void NewPlanThresholdTotalAmountValidationWorks() } [Fact] - public void NewPlanTieredPackageValidationWorks() + public void TieredPackageValidationWorks() { - Price value = new Models::NewPlanTieredPackagePrice() + LicenseAllocationPrice value = new TieredPackage() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = TieredPackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredPackageConfig = new() { @@ -2385,13 +3080,21 @@ public void NewPlanTieredPackageValidationWorks() } [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void TieredWithMinimumValidationWorks() { - Price value = new Models::NewPlanTieredWithMinimumPrice() + LicenseAllocationPrice value = new TieredWithMinimum() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithMinimumConfig = new() { @@ -2449,11 +3152,11 @@ public void NewPlanTieredWithMinimumValidationWorks() } [Fact] - public void NewPlanGroupedTieredValidationWorks() + public void GroupedTieredValidationWorks() { - Price value = new Models::NewPlanGroupedTieredPrice() + LicenseAllocationPrice value = new GroupedTiered() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + Cadence = GroupedTieredCadence.Annual, GroupedTieredConfig = new() { GroupingKey = "x", @@ -2464,7 +3167,15 @@ public void NewPlanGroupedTieredValidationWorks() ], }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2502,14 +3213,21 @@ public void NewPlanGroupedTieredValidationWorks() } [Fact] - public void NewPlanTieredPackageWithMinimumValidationWorks() + public void TieredPackageWithMinimumValidationWorks() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + LicenseAllocationPrice value = new TieredPackageWithMinimum() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredPackageWithMinimumConfig = new() { @@ -2566,13 +3284,21 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() } [Fact] - public void NewPlanPackageWithAllocationValidationWorks() + public void PackageWithAllocationValidationWorks() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + LicenseAllocationPrice value = new PackageWithAllocation() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PackageWithAllocationConfig = new() { @@ -2616,13 +3342,21 @@ public void NewPlanPackageWithAllocationValidationWorks() } [Fact] - public void NewPlanUnitWithPercentValidationWorks() + public void UnitWithPercentValidationWorks() { - Price value = new Models::NewPlanUnitWithPercentPrice() + LicenseAllocationPrice value = new UnitWithPercent() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = UnitWithPercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", @@ -2661,12 +3395,21 @@ public void NewPlanUnitWithPercentValidationWorks() } [Fact] - public void NewPlanMatrixWithAllocationValidationWorks() + public void MatrixWithAllocationValidationWorks() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + LicenseAllocationPrice value = new MatrixWithAllocation() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = MatrixWithAllocationCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixWithAllocationConfig = new() { Allocation = "allocation", @@ -2674,7 +3417,6 @@ public void NewPlanMatrixWithAllocationValidationWorks() Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2714,10 +3456,19 @@ public void NewPlanMatrixWithAllocationValidationWorks() [Fact] public void TieredWithProrationValidationWorks() { - Price value = new TieredWithProration() + LicenseAllocationPrice value = new TieredWithProration() { Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithProrationConfig = new( [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] @@ -2758,13 +3509,21 @@ public void TieredWithProrationValidationWorks() } [Fact] - public void NewPlanUnitWithProrationValidationWorks() + public void UnitWithProrationValidationWorks() { - Price value = new Models::NewPlanUnitWithProrationPrice() + LicenseAllocationPrice value = new UnitWithProration() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = UnitWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", @@ -2803,11 +3562,11 @@ public void NewPlanUnitWithProrationValidationWorks() } [Fact] - public void NewPlanGroupedAllocationValidationWorks() + public void GroupedAllocationValidationWorks() { - Price value = new Models::NewPlanGroupedAllocationPrice() + LicenseAllocationPrice value = new GroupedAllocation() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + Cadence = GroupedAllocationCadence.Annual, GroupedAllocationConfig = new() { Allocation = "allocation", @@ -2815,7 +3574,15 @@ public void NewPlanGroupedAllocationValidationWorks() OverageUnitRate = "overage_unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2853,9 +3620,9 @@ public void NewPlanGroupedAllocationValidationWorks() } [Fact] - public void NewPlanBulkWithProrationValidationWorks() + public void BulkWithProrationValidationWorks() { - Price value = new Models::NewPlanBulkWithProrationPrice() + LicenseAllocationPrice value = new BulkWithProration() { BulkWithProrationConfig = new( [ @@ -2863,9 +3630,17 @@ public void NewPlanBulkWithProrationValidationWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ] ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = BulkWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2903,11 +3678,11 @@ public void NewPlanBulkWithProrationValidationWorks() } [Fact] - public void NewPlanGroupedWithProratedMinimumValidationWorks() + public void GroupedWithProratedMinimumValidationWorks() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + LicenseAllocationPrice value = new GroupedWithProratedMinimum() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + Cadence = GroupedWithProratedMinimumCadence.Annual, GroupedWithProratedMinimumConfig = new() { GroupingKey = "x", @@ -2915,8 +3690,15 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() UnitRate = "unit_rate", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2954,11 +3736,11 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() } [Fact] - public void NewPlanGroupedWithMeteredMinimumValidationWorks() + public void GroupedWithMeteredMinimumValidationWorks() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + LicenseAllocationPrice value = new GroupedWithMeteredMinimum() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + Cadence = GroupedWithMeteredMinimumCadence.Annual, GroupedWithMeteredMinimumConfig = new() { GroupingKey = "x", @@ -2966,17 +3748,24 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() PricingKey = "pricing_key", ScalingFactors = [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, ], ScalingKey = "scaling_key", UnitAmounts = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, ], }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3016,7 +3805,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() [Fact] public void GroupedWithMinMaxThresholdsValidationWorks() { - Price value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -3027,6 +3816,15 @@ public void GroupedWithMinMaxThresholdsValidationWorks() PerUnitRate = "per_unit_rate", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3064,12 +3862,21 @@ public void GroupedWithMinMaxThresholdsValidationWorks() } [Fact] - public void NewPlanMatrixWithDisplayNameValidationWorks() + public void MatrixWithDisplayNameValidationWorks() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + LicenseAllocationPrice value = new MatrixWithDisplayName() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = MatrixWithDisplayNameCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixWithDisplayNameConfig = new() { Dimension = "dimension", @@ -3083,7 +3890,6 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3121,11 +3927,11 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() } [Fact] - public void NewPlanGroupedTieredPackageValidationWorks() + public void GroupedTieredPackageValidationWorks() { - Price value = new Models::NewPlanGroupedTieredPackagePrice() + LicenseAllocationPrice value = new GroupedTieredPackage() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + Cadence = GroupedTieredPackageCadence.Annual, GroupedTieredPackageConfig = new() { GroupingKey = "x", @@ -3137,7 +3943,15 @@ public void NewPlanGroupedTieredPackageValidationWorks() ], }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3175,12 +3989,21 @@ public void NewPlanGroupedTieredPackageValidationWorks() } [Fact] - public void NewPlanMaxGroupTieredPackageValidationWorks() + public void MaxGroupTieredPackageValidationWorks() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + LicenseAllocationPrice value = new MaxGroupTieredPackage() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = MaxGroupTieredPackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MaxGroupTieredPackageConfig = new() { GroupingKey = "x", @@ -3191,7 +4014,6 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3229,14 +4051,21 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void ScalableMatrixWithUnitPricingValidationWorks() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + LicenseAllocationPrice value = new ScalableMatrixWithUnitPricing() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ScalableMatrixWithUnitPricingConfig = new() { @@ -3291,14 +4120,21 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void ScalableMatrixWithTieredPricingValidationWorks() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + LicenseAllocationPrice value = new ScalableMatrixWithTieredPricing() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ScalableMatrixWithTieredPricingConfig = new() { @@ -3355,11 +4191,11 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void CumulativeGroupedBulkValidationWorks() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + LicenseAllocationPrice value = new CumulativeGroupedBulk() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + Cadence = CumulativeGroupedBulkCadence.Annual, CumulativeGroupedBulkConfig = new() { DimensionValues = @@ -3374,7 +4210,15 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Group = "group", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3414,7 +4258,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() [Fact] public void CumulativeGroupedAllocationValidationWorks() { - Price value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -3425,6 +4269,15 @@ public void CumulativeGroupedAllocationValidationWorks() UnitAmount = "unit_amount", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3462,14 +4315,22 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void MinimumCompositeValidationWorks() { - Price value = new Models::NewPlanMinimumCompositePrice() + LicenseAllocationPrice value = new MinimumComposite() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = MinimumCompositeCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3509,10 +4370,19 @@ public void NewPlanMinimumCompositeValidationWorks() [Fact] public void PercentValidationWorks() { - Price value = new Percent() + LicenseAllocationPrice value = new Percent() { Cadence = PercentCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PercentConfig = new(0), BillableMetricID = "billable_metric_id", @@ -3553,7 +4423,7 @@ public void PercentValidationWorks() [Fact] public void EventOutputValidationWorks() { - Price value = new EventOutput() + LicenseAllocationPrice value = new EventOutput() { Cadence = EventOutputCadence.Annual, EventOutputConfig = new() @@ -3563,6 +4433,15 @@ public void EventOutputValidationWorks() GroupingKey = "grouping_key", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3600,13 +4479,21 @@ public void EventOutputValidationWorks() } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Price value = new Models::NewPlanUnitPrice() + LicenseAllocationPrice value = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", @@ -3642,19 +4529,30 @@ public void NewPlanUnitSerializationRoundtripWorks() 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 NewPlanTieredSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPrice() + LicenseAllocationPrice value = new Tiered() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredConfig = new() { @@ -3702,20 +4600,31 @@ public void NewPlanTieredSerializationRoundtripWorks() 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 NewPlanBulkSerializationRoundtripWorks() + public void BulkSerializationRoundtripWorks() { - Price value = new Models::NewPlanBulkPrice() + LicenseAllocationPrice value = new Bulk() { BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = BulkCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3750,7 +4659,10 @@ public void NewPlanBulkSerializationRoundtripWorks() 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); } @@ -3758,7 +4670,7 @@ public void NewPlanBulkSerializationRoundtripWorks() [Fact] public void BulkWithFiltersSerializationRoundtripWorks() { - Price value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -3769,8 +4681,17 @@ public void BulkWithFiltersSerializationRoundtripWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3805,19 +4726,30 @@ public void BulkWithFiltersSerializationRoundtripWorks() 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 NewPlanPackageSerializationRoundtripWorks() + public void PackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanPackagePrice() + LicenseAllocationPrice value = new Package() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", @@ -3853,25 +4785,36 @@ public void NewPlanPackageSerializationRoundtripWorks() 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 NewPlanMatrixSerializationRoundtripWorks() + public void MatrixSerializationRoundtripWorks() { - Price value = new Models::NewPlanMatrixPrice() + LicenseAllocationPrice value = new Matrix() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = MatrixCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixConfig = new() { DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3906,19 +4849,30 @@ public void NewPlanMatrixSerializationRoundtripWorks() 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void ThresholdTotalAmountSerializationRoundtripWorks() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + LicenseAllocationPrice value = new ThresholdTotalAmount() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = ThresholdTotalAmountCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ThresholdTotalAmountConfig = new() { @@ -3962,19 +4916,30 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() 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 NewPlanTieredPackageSerializationRoundtripWorks() + public void TieredPackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPackagePrice() + LicenseAllocationPrice value = new TieredPackage() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = TieredPackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredPackageConfig = new() { @@ -4018,19 +4983,30 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void TieredWithMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredWithMinimumPrice() + LicenseAllocationPrice value = new TieredWithMinimum() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithMinimumConfig = new() { @@ -4085,17 +5061,20 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() 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 NewPlanGroupedTieredSerializationRoundtripWorks() + public void GroupedTieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedTieredPrice() + LicenseAllocationPrice value = new GroupedTiered() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + Cadence = GroupedTieredCadence.Annual, GroupedTieredConfig = new() { GroupingKey = "x", @@ -4106,7 +5085,15 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() ], }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4141,20 +5128,30 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void TieredPackageWithMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + LicenseAllocationPrice value = new TieredPackageWithMinimum() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredPackageWithMinimumConfig = new() { @@ -4208,19 +5205,30 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void PackageWithAllocationSerializationRoundtripWorks() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + LicenseAllocationPrice value = new PackageWithAllocation() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PackageWithAllocationConfig = new() { @@ -4261,19 +5269,30 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() 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 NewPlanUnitWithPercentSerializationRoundtripWorks() + public void UnitWithPercentSerializationRoundtripWorks() { - Price value = new Models::NewPlanUnitWithPercentPrice() + LicenseAllocationPrice value = new UnitWithPercent() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = UnitWithPercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", @@ -4309,18 +5328,30 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() 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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void MatrixWithAllocationSerializationRoundtripWorks() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + LicenseAllocationPrice value = new MatrixWithAllocation() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = MatrixWithAllocationCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixWithAllocationConfig = new() { Allocation = "allocation", @@ -4328,7 +5359,6 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4363,7 +5393,10 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() 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); } @@ -4371,10 +5404,19 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() [Fact] public void TieredWithProrationSerializationRoundtripWorks() { - Price value = new TieredWithProration() + LicenseAllocationPrice value = new TieredWithProration() { Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithProrationConfig = new( [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] @@ -4412,19 +5454,30 @@ public void TieredWithProrationSerializationRoundtripWorks() 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + public void UnitWithProrationSerializationRoundtripWorks() { - Price value = new Models::NewPlanUnitWithProrationPrice() + LicenseAllocationPrice value = new UnitWithProration() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = UnitWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", @@ -4460,17 +5513,20 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() 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 NewPlanGroupedAllocationSerializationRoundtripWorks() + public void GroupedAllocationSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedAllocationPrice() + LicenseAllocationPrice value = new GroupedAllocation() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + Cadence = GroupedAllocationCadence.Annual, GroupedAllocationConfig = new() { Allocation = "allocation", @@ -4478,7 +5534,15 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() OverageUnitRate = "overage_unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4513,15 +5577,18 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() 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 NewPlanBulkWithProrationSerializationRoundtripWorks() + public void BulkWithProrationSerializationRoundtripWorks() { - Price value = new Models::NewPlanBulkWithProrationPrice() + LicenseAllocationPrice value = new BulkWithProration() { BulkWithProrationConfig = new( [ @@ -4529,9 +5596,17 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ] ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = BulkWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4566,17 +5641,20 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void GroupedWithProratedMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + LicenseAllocationPrice value = new GroupedWithProratedMinimum() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + Cadence = GroupedWithProratedMinimumCadence.Annual, GroupedWithProratedMinimumConfig = new() { GroupingKey = "x", @@ -4584,8 +5662,15 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() UnitRate = "unit_rate", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4620,17 +5705,20 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void GroupedWithMeteredMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + LicenseAllocationPrice value = new GroupedWithMeteredMinimum() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + Cadence = GroupedWithMeteredMinimumCadence.Annual, GroupedWithMeteredMinimumConfig = new() { GroupingKey = "x", @@ -4638,17 +5726,24 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() PricingKey = "pricing_key", ScalingFactors = [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, ], ScalingKey = "scaling_key", UnitAmounts = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, ], }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4683,7 +5778,10 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() 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); } @@ -4691,7 +5789,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() [Fact] public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - Price value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -4702,6 +5800,15 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() PerUnitRate = "per_unit_rate", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4736,18 +5843,30 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void MatrixWithDisplayNameSerializationRoundtripWorks() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + LicenseAllocationPrice value = new MatrixWithDisplayName() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = MatrixWithDisplayNameCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MatrixWithDisplayNameConfig = new() { Dimension = "dimension", @@ -4761,7 +5880,6 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4796,17 +5914,20 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void GroupedTieredPackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedTieredPackagePrice() + LicenseAllocationPrice value = new GroupedTieredPackage() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + Cadence = GroupedTieredPackageCadence.Annual, GroupedTieredPackageConfig = new() { GroupingKey = "x", @@ -4818,7 +5939,15 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() ], }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4853,18 +5982,30 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void MaxGroupTieredPackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + LicenseAllocationPrice value = new MaxGroupTieredPackage() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = MaxGroupTieredPackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MaxGroupTieredPackageConfig = new() { GroupingKey = "x", @@ -4875,7 +6016,6 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4910,20 +6050,30 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + LicenseAllocationPrice value = new ScalableMatrixWithUnitPricing() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ScalableMatrixWithUnitPricingConfig = new() { @@ -4975,20 +6125,30 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + LicenseAllocationPrice value = new ScalableMatrixWithTieredPricing() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", ScalableMatrixWithTieredPricingConfig = new() { @@ -5042,17 +6202,20 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() 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 NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void CumulativeGroupedBulkSerializationRoundtripWorks() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + LicenseAllocationPrice value = new CumulativeGroupedBulk() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + Cadence = CumulativeGroupedBulkCadence.Annual, CumulativeGroupedBulkConfig = new() { DimensionValues = @@ -5067,7 +6230,15 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Group = "group", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5102,7 +6273,10 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() 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); } @@ -5110,7 +6284,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() [Fact] public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -5121,6 +6295,15 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() UnitAmount = "unit_amount", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5155,20 +6338,31 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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 NewPlanMinimumCompositeSerializationRoundtripWorks() + public void MinimumCompositeSerializationRoundtripWorks() { - Price value = new Models::NewPlanMinimumCompositePrice() + LicenseAllocationPrice value = new MinimumComposite() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = MinimumCompositeCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5203,7 +6397,10 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() 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); } @@ -5211,10 +6408,19 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() [Fact] public void PercentSerializationRoundtripWorks() { - Price value = new Percent() + LicenseAllocationPrice value = new Percent() { Cadence = PercentCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PercentConfig = new(0), BillableMetricID = "billable_metric_id", @@ -5250,7 +6456,10 @@ public void PercentSerializationRoundtripWorks() 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); } @@ -5258,7 +6467,7 @@ public void PercentSerializationRoundtripWorks() [Fact] public void EventOutputSerializationRoundtripWorks() { - Price value = new EventOutput() + LicenseAllocationPrice value = new EventOutput() { Cadence = EventOutputCadence.Annual, EventOutputConfig = new() @@ -5268,6 +6477,15 @@ public void EventOutputSerializationRoundtripWorks() GroupingKey = "grouping_key", }, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5302,31 +6520,35 @@ public void EventOutputSerializationRoundtripWorks() 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 BulkWithFiltersTest : TestBase +public class UnitTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5360,19 +6582,24 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - 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 = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -5406,11 +6633,16 @@ 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitConfig, model.UnitConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -5437,20 +6669,21 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5485,10 +6718,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); } @@ -5496,20 +6726,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5544,25 +6775,27 @@ 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); - 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 = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -5596,11 +6829,16 @@ 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitConfig, deserialized.UnitConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -5630,20 +6868,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5683,20 +6922,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }; Assert.Null(model.BillableMetricID); @@ -5732,20 +6972,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }; model.Validate(); @@ -5754,20 +6995,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = null, BilledInAdvance = null, @@ -5818,20 +7060,21 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = null, BilledInAdvance = null, @@ -5855,20 +7098,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new BulkWithFilters + var model = new Unit { - 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 = Cadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5902,223 +7146,114 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - BulkWithFilters copied = new(model); + Unit copied = new(model); Assert.Equal(model, copied); } } -public class BulkWithFiltersConfigTest : TestBase +public class CadenceTest : TestBase { - [Fact] - public void FieldRoundtrip_Works() + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void Validation_Works(Cadence rawValue) { - var model = new 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]); - } + // 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 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, + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void SerializationRoundtrip_Works(Cadence rawValue) { - var model = new BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, 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 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(); - } - - [Fact] - public void CopyConstructor_Works() - { - var model = new BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - BulkWithFiltersConfig copied = new(model); - - Assert.Equal(model, copied); - } -} - -public class FilterTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new 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 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 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 Filter { PropertyKey = "x", PropertyValue = "x" }; - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void CopyConstructor_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - Filter copied = new(model); + 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(model, copied); + Assert.Equal(value, deserialized); } } -public class TierTest : TestBase +public class LicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; 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); } @@ -6126,23 +7261,38 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; 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 expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } @@ -6150,16 +7300,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Tier { UnitAmount = "unit_amount" }; + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Tier { UnitAmount = "unit_amount" }; + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; model.Validate(); } @@ -6167,25 +7317,27 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Tier + var model = new LicenseAllocation { - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", - TierLowerBound = null, + WriteOffOverage = null, }; - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Tier + var model = new LicenseAllocation { - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", - TierLowerBound = null, + WriteOffOverage = null, }; model.Validate(); @@ -6194,80 +7346,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - Tier copied = new(model); + LicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class CadenceTest : TestBase -{ - [Theory] - [InlineData(Cadence.Annual)] - [InlineData(Cadence.SemiAnnual)] - [InlineData(Cadence.Monthly)] - [InlineData(Cadence.Quarterly)] - [InlineData(Cadence.OneTime)] - [InlineData(Cadence.Custom)] - public void Validation_Works(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(Cadence.Annual)] - [InlineData(Cadence.SemiAnnual)] - [InlineData(Cadence.Monthly)] - [InlineData(Cadence.Quarterly)] - [InlineData(Cadence.OneTime)] - [InlineData(Cadence.Custom)] - public void SerializationRoundtrip_Works(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] @@ -6345,19 +7436,38 @@ public void TieredSerializationRoundtripWorks() } } -public class TieredWithProrationTest : TestBase +public class TieredTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6391,14 +7501,32 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = TieredCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); string expectedName = "Annual fee"; - TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6407,7 +7535,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + TieredConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6434,9 +7562,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); + Assert.Equal(expectedTieredConfig, model.TieredConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6463,14 +7596,33 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6505,10 +7657,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); } @@ -6516,14 +7665,33 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6558,20 +7726,35 @@ 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 = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = TieredCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); string expectedName = "Annual fee"; - TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6580,7 +7763,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + TieredConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6607,9 +7790,14 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); + Assert.Equal(expectedTieredConfig, deserialized.TieredConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -6639,14 +7827,33 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6686,14 +7893,33 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, }; Assert.Null(model.BillableMetricID); @@ -6729,14 +7955,33 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, }; model.Validate(); @@ -6745,14 +7990,33 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = null, BilledInAdvance = null, @@ -6803,14 +8067,33 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = null, BilledInAdvance = null, @@ -6834,14 +8117,33 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new TieredWithProration + var model = new Tiered { - Cadence = TieredWithProrationCadence.Annual, + Cadence = TieredCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6875,32 +8177,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - TieredWithProration copied = new(model); + Tiered copied = new(model); Assert.Equal(model, copied); } } -public class TieredWithProrationCadenceTest : TestBase +public class TieredCadenceTest : TestBase { [Theory] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Custom)] - public void Validation_Works(TieredWithProrationCadence rawValue) + [InlineData(TieredCadence.Annual)] + [InlineData(TieredCadence.SemiAnnual)] + [InlineData(TieredCadence.Monthly)] + [InlineData(TieredCadence.Quarterly)] + [InlineData(TieredCadence.OneTime)] + [InlineData(TieredCadence.Custom)] + public void Validation_Works(TieredCadence 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 ); @@ -6910,19 +8212,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) + [InlineData(TieredCadence.Annual)] + [InlineData(TieredCadence.SemiAnnual)] + [InlineData(TieredCadence.Monthly)] + [InlineData(TieredCadence.Quarterly)] + [InlineData(TieredCadence.OneTime)] + [InlineData(TieredCadence.Custom)] + public void SerializationRoundtrip_Works(TieredCadence 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 ); @@ -6933,12 +8235,12 @@ public void SerializationRoundtrip_Works(TieredWithProrationCadence 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 ); @@ -6947,38 +8249,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class TieredWithProrationConfigTest : TestBase +public class TieredLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new TieredLicenseAllocation { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new TieredLicenseAllocation { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6989,121 +8292,83 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfig + var model = new TieredLicenseAllocation { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfig + var model = new TieredLicenseAllocation { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); } [Fact] - public void CopyConstructor_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - TieredWithProrationConfig copied = new(model); + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; - Assert.Equal(model, copied); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + model.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProrationConfigTier + var model = new TieredLicenseAllocation { - 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); - } + Amount = "amount", + Currency = "currency", - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + WriteOffOverage = null, }; - 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); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProrationConfigTier + var model = new TieredLicenseAllocation { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, }; model.Validate(); @@ -7112,24 +8377,25 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new TieredWithProrationConfigTier + var model = new TieredLicenseAllocation { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - TieredWithProrationConfigTier copied = new(model); + TieredLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class TieredWithProrationConversionRateConfigTest : TestBase +public class TieredConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + TieredConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -7140,34 +8406,33 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - TieredWithProrationConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + TieredConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + TieredConversionRateConfig 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 ); @@ -7178,23 +8443,22 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + TieredConversionRateConfig 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7203,22 +8467,25 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedWithMinMaxThresholdsTest : TestBase +public class BulkTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7253,19 +8520,21 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - GroupedWithMinMaxThresholdsCadence.Annual; - 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" + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] ); + ApiEnum expectedCadence = BulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7275,7 +8544,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + BulkConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7300,12 +8569,14 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkConfig, model.BulkConfig); Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -7334,17 +8605,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7380,10 +8654,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); } @@ -7391,17 +8662,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7437,25 +8711,24 @@ 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 = - GroupedWithMinMaxThresholdsCadence.Annual; - 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" + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] ); + ApiEnum expectedCadence = BulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7465,7 +8738,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + BulkConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7490,12 +8763,14 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkConfig, deserialized.BulkConfig); Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -7527,21 +8802,24 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, @@ -7578,17 +8856,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", }; @@ -7625,17 +8906,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", }; @@ -7645,17 +8929,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = null, @@ -7707,17 +8994,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = null, @@ -7742,17 +9032,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Bulk { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7787,32 +9080,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - GroupedWithMinMaxThresholds copied = new(model); + Bulk copied = new(model); Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class BulkCadenceTest : TestBase { [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(GroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(BulkCadence.Annual)] + [InlineData(BulkCadence.SemiAnnual)] + [InlineData(BulkCadence.Monthly)] + [InlineData(BulkCadence.Quarterly)] + [InlineData(BulkCadence.OneTime)] + [InlineData(BulkCadence.Custom)] + public void Validation_Works(BulkCadence 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 ); @@ -7822,21 +9115,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(BulkCadence.Annual)] + [InlineData(BulkCadence.SemiAnnual)] + [InlineData(BulkCadence.Monthly)] + [InlineData(BulkCadence.Quarterly)] + [InlineData(BulkCadence.OneTime)] + [InlineData(BulkCadence.Custom)] + public void SerializationRoundtrip_Works(BulkCadence 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 - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -7844,56 +9138,53 @@ public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence rawV [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< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class GroupedWithMinMaxThresholdsConfigTest : TestBase +public class BulkLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7904,41 +9195,83 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, }; model.Validate(); @@ -7947,70 +9280,65 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new BulkLicenseAllocation { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - GroupedWithMinMaxThresholdsConfig copied = new(model); + BulkLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class BulkConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + BulkConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + BulkConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + BulkConversionRateConfig 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); } @@ -8018,48 +9346,57 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + BulkConversionRateConfig 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 - ); + 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 CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8094,19 +9431,27 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig expectedBulkWithFiltersConfig = 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" }, + ], }; + ApiEnum expectedCadence = BulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8116,7 +9461,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + BulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8141,12 +9486,14 @@ 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -8175,17 +9522,28 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8221,7 +9579,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8232,17 +9590,28 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8278,25 +9647,33 @@ 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 = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig expectedBulkWithFiltersConfig = 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" }, + ], }; + ApiEnum expectedCadence = BulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8306,7 +9683,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + BulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8331,12 +9708,14 @@ 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -8368,17 +9747,28 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8419,17 +9809,28 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", }; @@ -8466,17 +9867,28 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", }; @@ -8486,19 +9898,30 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - + 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.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + BillableMetricID = null, BilledInAdvance = null, BillingCycleConfiguration = null, @@ -8548,17 +9971,28 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = null, @@ -8583,17 +10017,28 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new CumulativeGroupedAllocation + var model = new BulkWithFilters { - Cadence = 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8628,32 +10073,326 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - CumulativeGroupedAllocation copied = new(model); + BulkWithFilters copied = new(model); Assert.Equal(model, copied); } } -public class CumulativeGroupedAllocationCadenceTest : TestBase +public class BulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 SerializationRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new 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 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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 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 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 Filter { PropertyKey = "x", PropertyValue = "x" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Tier { 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 Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Tier { UnitAmount = "unit_amount" }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Tier { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new 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 Tier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithFiltersCadenceTest : TestBase { [Theory] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(BulkWithFiltersCadence.Annual)] + [InlineData(BulkWithFiltersCadence.SemiAnnual)] + [InlineData(BulkWithFiltersCadence.Monthly)] + [InlineData(BulkWithFiltersCadence.Quarterly)] + [InlineData(BulkWithFiltersCadence.OneTime)] + [InlineData(BulkWithFiltersCadence.Custom)] + public void Validation_Works(BulkWithFiltersCadence 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 ); @@ -8663,21 +10402,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(BulkWithFiltersCadence.Annual)] + [InlineData(BulkWithFiltersCadence.SemiAnnual)] + [InlineData(BulkWithFiltersCadence.Monthly)] + [InlineData(BulkWithFiltersCadence.Quarterly)] + [InlineData(BulkWithFiltersCadence.OneTime)] + [InlineData(BulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works(BulkWithFiltersCadence 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 - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -8685,56 +10425,53 @@ public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawV [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< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class BulkWithFiltersLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8745,157 +10482,209 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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 expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); } [Fact] - public void CopyConstructor_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersLicenseAllocation { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Amount = "amount", + Currency = "currency", }; - CumulativeGroupedAllocationConfig copied = new(model); - - Assert.Equal(model, copied); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } -} -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); } [Fact] - public void TieredValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void UnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - CumulativeGroupedAllocationConversionRateConfig 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 model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", - Assert.Equal(value, deserialized); + WriteOffOverage = null, + }; + + model.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void CopyConstructor_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + BulkWithFiltersLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithFiltersConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithFiltersConversionRateConfig 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); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + BulkWithFiltersConversionRateConfig 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 +public class PackageTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8929,11 +10718,24 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = PercentCadence.Annual; + ApiEnum expectedCadence = PackageCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8942,7 +10744,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + PackageConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8969,9 +10771,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPercentConfig, model.PercentConfig); + Assert.Equal(expectedPackageConfig, model.PackageConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8998,12 +10805,21 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9038,7 +10854,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); } @@ -9046,12 +10862,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9086,17 +10911,30 @@ 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 = PackageCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9105,7 +10943,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + PackageConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9132,9 +10970,14 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); + Assert.Equal(expectedPackageConfig, deserialized.PackageConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9164,12 +11007,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9209,12 +11061,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, }; Assert.Null(model.BillableMetricID); @@ -9250,12 +11111,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, }; model.Validate(); @@ -9264,12 +11134,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = null, BilledInAdvance = null, @@ -9320,12 +11199,21 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = null, BilledInAdvance = null, @@ -9349,12 +11237,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Percent + var model = new Package { - Cadence = PercentCadence.Annual, + Cadence = PackageCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PercentConfig = new(0), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9388,32 +11285,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - Percent copied = new(model); + Package copied = new(model); Assert.Equal(model, copied); } } -public class PercentCadenceTest : TestBase +public class PackageCadenceTest : 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(PackageCadence.Annual)] + [InlineData(PackageCadence.SemiAnnual)] + [InlineData(PackageCadence.Monthly)] + [InlineData(PackageCadence.Quarterly)] + [InlineData(PackageCadence.OneTime)] + [InlineData(PackageCadence.Custom)] + public void Validation_Works(PackageCadence 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 ); @@ -9423,19 +11320,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(PackageCadence.Annual)] + [InlineData(PackageCadence.SemiAnnual)] + [InlineData(PackageCadence.Monthly)] + [InlineData(PackageCadence.Quarterly)] + [InlineData(PackageCadence.OneTime)] + [InlineData(PackageCadence.Custom)] + public void SerializationRoundtrip_Works(PackageCadence 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 ); @@ -9446,12 +11343,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 ); @@ -9460,25 +11357,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PercentConfigTest : TestBase +public class PackageLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - double expectedPercent = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9489,24 +11400,84 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; 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 expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; model.Validate(); } @@ -9514,20 +11485,25 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - PercentConfig copied = new(model); + PackageLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class PercentConversionRateConfigTest : TestBase +public class PackageConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PackageConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -9538,7 +11514,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9558,13 +11534,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PackageConversionRateConfig 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 ); @@ -9575,7 +11551,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9590,7 +11566,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9599,21 +11575,30 @@ public void TieredSerializationRoundtripWorks() } } -public class EventOutputTest : TestBase +public class MatrixTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9648,15 +11633,24 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = MatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9666,7 +11660,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + MatrixConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9692,8 +11686,13 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, model.MatrixConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -9722,16 +11721,25 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9767,10 +11775,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); } @@ -9778,16 +11783,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9823,21 +11837,27 @@ 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 = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = MatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9847,7 +11867,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + MatrixConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9873,8 +11893,13 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, deserialized.MatrixConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -9906,16 +11931,25 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9956,16 +11990,25 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", }; @@ -10002,16 +12045,25 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", }; @@ -10021,16 +12073,25 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -10082,16 +12143,25 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -10116,16 +12186,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new EventOutput + var model = new Matrix { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -10160,32 +12239,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - EventOutput copied = new(model); + Matrix copied = new(model); Assert.Equal(model, copied); } } -public class EventOutputCadenceTest : TestBase +public class MatrixCadenceTest : 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) + [InlineData(MatrixCadence.Annual)] + [InlineData(MatrixCadence.SemiAnnual)] + [InlineData(MatrixCadence.Monthly)] + [InlineData(MatrixCadence.Quarterly)] + [InlineData(MatrixCadence.OneTime)] + [InlineData(MatrixCadence.Custom)] + public void Validation_Works(MatrixCadence 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 ); @@ -10195,19 +12274,19 @@ public void InvalidEnumValidationThrows_Works() } [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) + [InlineData(MatrixCadence.Annual)] + [InlineData(MatrixCadence.SemiAnnual)] + [InlineData(MatrixCadence.Monthly)] + [InlineData(MatrixCadence.Quarterly)] + [InlineData(MatrixCadence.OneTime)] + [InlineData(MatrixCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixCadence 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 ); @@ -10218,12 +12297,12 @@ public void SerializationRoundtrip_Works(EventOutputCadence 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 ); @@ -10232,39 +12311,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class EventOutputConfigTest : TestBase +public class MatrixLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10275,37 +12354,37 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; 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 expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); @@ -10314,18 +12393,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new MatrixLicenseAllocation { Amount = "amount", Currency = "currency" }; - 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.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new MatrixLicenseAllocation { Amount = "amount", Currency = "currency" }; model.Validate(); } @@ -10333,29 +12410,27 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", + Amount = "amount", + Currency = "currency", - DefaultUnitRate = null, - GroupingKey = null, + WriteOffOverage = 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.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", + Amount = "amount", + Currency = "currency", - DefaultUnitRate = null, - GroupingKey = null, + WriteOffOverage = null, }; model.Validate(); @@ -10364,25 +12439,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new EventOutputConfig + var model = new MatrixLicenseAllocation { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - EventOutputConfig copied = new(model); + MatrixLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class EventOutputConversionRateConfigTest : TestBase +public class MatrixConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MatrixConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -10393,7 +12468,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + MatrixConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -10413,13 +12488,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MatrixConversionRateConfig 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 ); @@ -10430,7 +12505,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + MatrixConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -10445,7 +12520,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10454,27 +12529,217 @@ public void TieredSerializationRoundtripWorks() } } -public class RemoveAdjustmentTest : TestBase +public class ThresholdTotalAmountTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; + ApiEnum expectedCadence = + ThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, model.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ); @@ -10485,26 +12750,219 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; + ApiEnum expectedCadence = + ThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, deserialized.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; model.Validate(); } @@ -10512,16 +12970,88 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 RemoveAdjustment { AdjustmentID = "adjustment_id" }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; model.Validate(); } @@ -10529,25 +13059,117 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new RemoveAdjustment + var model = new ThresholdTotalAmount { - AdjustmentID = "adjustment_id", + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, - PlanPhaseOrder = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 RemoveAdjustment + var model = new ThresholdTotalAmount { - AdjustmentID = "adjustment_id", + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, - PlanPhaseOrder = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); @@ -10556,35 +13178,167 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; - RemoveAdjustment copied = new(model); + ThresholdTotalAmount copied = new(model); Assert.Equal(model, copied); } } -public class RemovePriceTest : TestBase +public class ThresholdTotalAmountCadenceTest : TestBase +{ + [Theory] + [InlineData(ThresholdTotalAmountCadence.Annual)] + [InlineData(ThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ThresholdTotalAmountCadence.Monthly)] + [InlineData(ThresholdTotalAmountCadence.Quarterly)] + [InlineData(ThresholdTotalAmountCadence.OneTime)] + [InlineData(ThresholdTotalAmountCadence.Custom)] + public void Validation_Works(ThresholdTotalAmountCadence 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(ThresholdTotalAmountCadence.Annual)] + [InlineData(ThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ThresholdTotalAmountCadence.Monthly)] + [InlineData(ThresholdTotalAmountCadence.Quarterly)] + [InlineData(ThresholdTotalAmountCadence.OneTime)] + [InlineData(ThresholdTotalAmountCadence.Custom)] + public void SerializationRoundtrip_Works(ThresholdTotalAmountCadence 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 ThresholdTotalAmountLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10595,26 +13349,38 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } @@ -10622,16 +13388,24 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new RemovePrice { PriceID = "price_id" }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new RemovePrice { PriceID = "price_id" }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; model.Validate(); } @@ -10639,25 +13413,27 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new RemovePrice + var model = new ThresholdTotalAmountLicenseAllocation { - PriceID = "price_id", + Amount = "amount", + Currency = "currency", - PlanPhaseOrder = null, + WriteOffOverage = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new RemovePrice + var model = new ThresholdTotalAmountLicenseAllocation { - PriceID = "price_id", + Amount = "amount", + Currency = "currency", - PlanPhaseOrder = null, + WriteOffOverage = null, }; model.Validate(); @@ -10666,104 +13442,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - RemovePrice copied = new(model); + ThresholdTotalAmountLicenseAllocation copied = new(model); Assert.Equal(model, copied); } } -public class ReplaceAdjustmentTest : TestBase +public class ThresholdTotalAmountConfigTest : TestBase { [Fact] public void FieldRoundtrip_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 = 0, - }; - - ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() + var model = new ThresholdTotalAmountConfig { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + ConsumptionTable = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Prorate = true, }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; + + Assert.Equal(expectedConsumptionTable.Count, model.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], model.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, model.Prorate); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10774,94 +13510,49 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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, - }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedConsumptionTable.Count, deserialized.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], deserialized.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, deserialized.Prorate); } [Fact] public void Validation_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; model.Validate(); @@ -10870,61 +13561,29 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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", + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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", + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], }; model.Validate(); @@ -10933,65 +13592,33 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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", + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], - PlanPhaseOrder = null, + Prorate = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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", + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], - PlanPhaseOrder = null, + Prorate = null, }; model.Validate(); @@ -11000,228 +13627,134 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountConfig { - 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, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; - ReplaceAdjustment copied = new(model); + ThresholdTotalAmountConfig copied = new(model); Assert.Equal(model, copied); } } -public class ReplaceAdjustmentAdjustmentTest : TestBase +public class ConsumptionTableTest : TestBase { [Fact] - public void NewPercentageDiscountValidationWorks() + public void FieldRoundtrip_Works() { - ReplaceAdjustmentAdjustment value = 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, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, model.Threshold); + Assert.Equal(expectedTotalAmount, model.TotalAmount); } [Fact] - public void NewUsageDiscountValidationWorks() + public void SerializationRoundtrip_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() - { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewUsageDiscountFilterField.PriceID, - Operator = Models::NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewUsageDiscountPriceType.Usage, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewAmountDiscountValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() - { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.Usage, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, deserialized.Threshold); + Assert.Equal(expectedTotalAmount, deserialized.TotalAmount); } [Fact] - public void NewMinimumValidationWorks() + public void Validation_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() - { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.Usage, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + model.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void CopyConstructor_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() - { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMaximumFilterField.PriceID, - Operator = Models::NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMaximumPriceType.Usage, - }; - value.Validate(); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + ConsumptionTable copied = new(model); + + Assert.Equal(model, copied); } +} +public class ThresholdTotalAmountConversionRateConfigTest : TestBase +{ [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void UnitValidationWorks() { - ReplaceAdjustmentAdjustment value = 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 element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } - Assert.Equal(value, deserialized); + [Fact] + public void TieredValidationWorks() + { + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() - { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewUsageDiscountFilterField.PriceID, - Operator = Models::NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewUsageDiscountPriceType.Usage, - }; + ThresholdTotalAmountConversionRateConfig 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 ); @@ -11230,211 +13763,61 @@ public void NewUsageDiscountSerializationRoundtripWorks() } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() - { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.Usage, - }; + ThresholdTotalAmountConversionRateConfig 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } +} +public class TieredPackageTest : TestBase +{ [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + var model = new TieredPackage { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = TieredPackageCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + LicenseAllocations = [ new() { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewMaximumSerializationRoundtripWorks() - { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() - { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMaximumFilterField.PriceID, - Operator = Models::NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 FieldRoundtrip_Works() - { - var model = new ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Name = "Annual fee", + TieredPackageConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - LicenseTypeID = "license_type_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, - }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - }; - - string expectedReplacesPriceID = "replaces_price_id"; - Models::NewAllocationPrice expectedAllocationPrice = 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", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - long expectedPlanPhaseOrder = 0; - ReplacePricePrice expectedPrice = 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() @@ -11468,87 +13851,155 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); + ApiEnum expectedCadence = TieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + TieredPackageConfig expectedTieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageConfig, model.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePrice + var model = new TieredPackage { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ExpiresAtEndOfCadence = true, - Filters = + ], + Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - 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, - }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }, + LicenseTypeID = "license_type_id", + 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 ); @@ -11559,116 +14010,29 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePrice - { - 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", - LicenseTypeID = "license_type_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, - }, - LicenseTypeID = "license_type_id", - 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 expectedReplacesPriceID = "replaces_price_id"; - Models::NewAllocationPrice expectedAllocationPrice = new() + var model = new TieredPackage { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, ], - ItemID = "item_id", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - long expectedPlanPhaseOrder = 0; - ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() - { - Cadence = Models::NewPlanUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -11702,83 +14066,161 @@ public void FieldRoundtripThroughSerialization_Works() ReferenceID = "reference_id", }; - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); - } + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - [Fact] - public void Validation_Works() - { - var model = new ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + ApiEnum expectedCadence = TieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + 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", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + TieredPackageConfig expectedTieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() { - 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() + 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredPackageConfig, deserialized.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; model.Validate(); @@ -11787,20 +14229,88 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + var model = new TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - 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.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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + var model = new TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; model.Validate(); } @@ -11808,33 +14318,117 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePrice + var model = new TieredPackage { - ReplacesPriceID = "replaces_price_id", + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - 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.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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePrice + var model = new TieredPackage { - ReplacesPriceID = "replaces_price_id", + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); @@ -11843,82 +14437,79871 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new ReplacePrice + var model = new TieredPackage { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ExpiresAtEndOfCadence = true, - Filters = + ], + Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - LicenseTypeID = "license_type_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - 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, - }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - ReplacePrice copied = new(model); + TieredPackage copied = new(model); Assert.Equal(model, copied); } } +public class TieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredPackageCadence.Annual)] + [InlineData(TieredPackageCadence.SemiAnnual)] + [InlineData(TieredPackageCadence.Monthly)] + [InlineData(TieredPackageCadence.Quarterly)] + [InlineData(TieredPackageCadence.OneTime)] + [InlineData(TieredPackageCadence.Custom)] + public void Validation_Works(TieredPackageCadence 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(TieredPackageCadence.Annual)] + [InlineData(TieredPackageCadence.SemiAnnual)] + [InlineData(TieredPackageCadence.Monthly)] + [InlineData(TieredPackageCadence.Quarterly)] + [InlineData(TieredPackageCadence.OneTime)] + [InlineData(TieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(TieredPackageCadence 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 TieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredPackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + TieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + 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 TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredPackageConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredPackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredPackageConversionRateConfig 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() + { + TieredPackageConversionRateConfig 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 TieredWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = TieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + TieredWithMinimumConfig expectedTieredWithMinimumConfig = 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithMinimumConfig, model.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = TieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + TieredWithMinimumConfig expectedTieredWithMinimumConfig = 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithMinimumConfig, deserialized.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredWithMinimumCadence.Annual)] + [InlineData(TieredWithMinimumCadence.SemiAnnual)] + [InlineData(TieredWithMinimumCadence.Monthly)] + [InlineData(TieredWithMinimumCadence.Quarterly)] + [InlineData(TieredWithMinimumCadence.OneTime)] + [InlineData(TieredWithMinimumCadence.Custom)] + public void Validation_Works(TieredWithMinimumCadence 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(TieredWithMinimumCadence.Annual)] + [InlineData(TieredWithMinimumCadence.SemiAnnual)] + [InlineData(TieredWithMinimumCadence.Monthly)] + [InlineData(TieredWithMinimumCadence.Quarterly)] + [InlineData(TieredWithMinimumCadence.OneTime)] + [InlineData(TieredWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(TieredWithMinimumCadence 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 TieredWithMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, model.HideZeroAmountTiers); + Assert.Equal(expectedProrate, model.Prorate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + 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 TieredWithMinimumConfig + { + 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, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, deserialized.HideZeroAmountTiers); + Assert.Equal(expectedProrate, deserialized.Prorate); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + TieredWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredWithMinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredWithMinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredWithMinimumConversionRateConfig 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() + { + TieredWithMinimumConversionRateConfig 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 GroupedTieredTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = GroupedTieredCadence.Annual; + GroupedTieredConfig expectedGroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + GroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredConfig, model.GroupedTieredConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = GroupedTieredCadence.Annual; + GroupedTieredConfig expectedGroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + GroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredConfig, deserialized.GroupedTieredConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedTiered copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedTieredCadence.Annual)] + [InlineData(GroupedTieredCadence.SemiAnnual)] + [InlineData(GroupedTieredCadence.Monthly)] + [InlineData(GroupedTieredCadence.Quarterly)] + [InlineData(GroupedTieredCadence.OneTime)] + [InlineData(GroupedTieredCadence.Custom)] + public void Validation_Works(GroupedTieredCadence 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(GroupedTieredCadence.Annual)] + [InlineData(GroupedTieredCadence.SemiAnnual)] + [InlineData(GroupedTieredCadence.Monthly)] + [InlineData(GroupedTieredCadence.Quarterly)] + [InlineData(GroupedTieredCadence.OneTime)] + [InlineData(GroupedTieredCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedTieredCadence 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 GroupedTieredConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + GroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + GroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedTieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedTieredLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedTieredConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedTieredConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedTieredConversionRateConfig 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() + { + GroupedTieredConversionRateConfig 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 TieredPackageWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + TieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + TieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageWithMinimumConfig, model.TieredPackageWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + TieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + TieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedTieredPackageWithMinimumConfig, + deserialized.TieredPackageWithMinimumConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredPackageWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredPackageWithMinimumCadence.Annual)] + [InlineData(TieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(TieredPackageWithMinimumCadence.Monthly)] + [InlineData(TieredPackageWithMinimumCadence.Quarterly)] + [InlineData(TieredPackageWithMinimumCadence.OneTime)] + [InlineData(TieredPackageWithMinimumCadence.Custom)] + public void Validation_Works(TieredPackageWithMinimumCadence 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(TieredPackageWithMinimumCadence.Annual)] + [InlineData(TieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(TieredPackageWithMinimumCadence.Monthly)] + [InlineData(TieredPackageWithMinimumCadence.Quarterly)] + [InlineData(TieredPackageWithMinimumCadence.OneTime)] + [InlineData(TieredPackageWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(TieredPackageWithMinimumCadence 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 TieredPackageWithMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredPackageWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + TieredPackageWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + 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 TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredPackageWithMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredPackageWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredPackageWithMinimumConversionRateConfig 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() + { + TieredPackageWithMinimumConversionRateConfig 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 PackageWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + PackageWithAllocationConfig expectedPackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPackageWithAllocationConfig, model.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + PackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + PackageWithAllocationConfig expectedPackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPackageWithAllocationConfig, deserialized.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(PackageWithAllocationCadence.Annual)] + [InlineData(PackageWithAllocationCadence.SemiAnnual)] + [InlineData(PackageWithAllocationCadence.Monthly)] + [InlineData(PackageWithAllocationCadence.Quarterly)] + [InlineData(PackageWithAllocationCadence.OneTime)] + [InlineData(PackageWithAllocationCadence.Custom)] + public void Validation_Works(PackageWithAllocationCadence 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(PackageWithAllocationCadence.Annual)] + [InlineData(PackageWithAllocationCadence.SemiAnnual)] + [InlineData(PackageWithAllocationCadence.Monthly)] + [InlineData(PackageWithAllocationCadence.Quarterly)] + [InlineData(PackageWithAllocationCadence.OneTime)] + [InlineData(PackageWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(PackageWithAllocationCadence 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 PackageWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + PackageWithAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedPackageAmount, model.PackageAmount); + Assert.Equal(expectedPackageSize, model.PackageSize); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + 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 PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedPackageAmount, deserialized.PackageAmount); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + PackageWithAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PackageWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PackageWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PackageWithAllocationConversionRateConfig 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() + { + PackageWithAllocationConversionRateConfig 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 UnitWithPercentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = UnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + UnitWithPercentConfig expectedUnitWithPercentConfig = new() + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithPercentConfig, model.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = UnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + UnitWithPercentConfig expectedUnitWithPercentConfig = new() + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithPercentConfig, deserialized.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + UnitWithPercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentCadenceTest : TestBase +{ + [Theory] + [InlineData(UnitWithPercentCadence.Annual)] + [InlineData(UnitWithPercentCadence.SemiAnnual)] + [InlineData(UnitWithPercentCadence.Monthly)] + [InlineData(UnitWithPercentCadence.Quarterly)] + [InlineData(UnitWithPercentCadence.OneTime)] + [InlineData(UnitWithPercentCadence.Custom)] + public void Validation_Works(UnitWithPercentCadence 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(UnitWithPercentCadence.Annual)] + [InlineData(UnitWithPercentCadence.SemiAnnual)] + [InlineData(UnitWithPercentCadence.Monthly)] + [InlineData(UnitWithPercentCadence.Quarterly)] + [InlineData(UnitWithPercentCadence.OneTime)] + [InlineData(UnitWithPercentCadence.Custom)] + public void SerializationRoundtrip_Works(UnitWithPercentCadence 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 UnitWithPercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + UnitWithPercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", 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 UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + UnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + UnitWithPercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + UnitWithPercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + UnitWithPercentConversionRateConfig 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() + { + UnitWithPercentConversionRateConfig 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 MatrixWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + MatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, model.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + MatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, deserialized.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MatrixWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithAllocationCadence.Annual)] + [InlineData(MatrixWithAllocationCadence.SemiAnnual)] + [InlineData(MatrixWithAllocationCadence.Monthly)] + [InlineData(MatrixWithAllocationCadence.Quarterly)] + [InlineData(MatrixWithAllocationCadence.OneTime)] + [InlineData(MatrixWithAllocationCadence.Custom)] + public void Validation_Works(MatrixWithAllocationCadence 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(MatrixWithAllocationCadence.Annual)] + [InlineData(MatrixWithAllocationCadence.SemiAnnual)] + [InlineData(MatrixWithAllocationCadence.Monthly)] + [InlineData(MatrixWithAllocationCadence.Quarterly)] + [InlineData(MatrixWithAllocationCadence.OneTime)] + [InlineData(MatrixWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithAllocationCadence 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 MatrixWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MatrixWithAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithAllocationConversionRateConfig 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() + { + MatrixWithAllocationConversionRateConfig 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 TieredWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + TieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + TieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredWithProrationCadence.Annual)] + [InlineData(TieredWithProrationCadence.SemiAnnual)] + [InlineData(TieredWithProrationCadence.Monthly)] + [InlineData(TieredWithProrationCadence.Quarterly)] + [InlineData(TieredWithProrationCadence.OneTime)] + [InlineData(TieredWithProrationCadence.Custom)] + public void Validation_Works(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>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(TieredWithProrationCadence.Annual)] + [InlineData(TieredWithProrationCadence.SemiAnnual)] + [InlineData(TieredWithProrationCadence.Monthly)] + [InlineData(TieredWithProrationCadence.Quarterly)] + [InlineData(TieredWithProrationCadence.OneTime)] + [InlineData(TieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(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>( + 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 TieredWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 TieredWithProrationConfig + { + 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 TieredWithProrationConfig + { + 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 TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredWithProrationConversionRateConfig 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() + { + TieredWithProrationConversionRateConfig 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 UnitWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = UnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + UnitWithProrationConfig expectedUnitWithProrationConfig = new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 = UnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + UnitWithProrationConfig expectedUnitWithProrationConfig = new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithProrationConfig, deserialized.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + UnitWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(UnitWithProrationCadence.Annual)] + [InlineData(UnitWithProrationCadence.SemiAnnual)] + [InlineData(UnitWithProrationCadence.Monthly)] + [InlineData(UnitWithProrationCadence.Quarterly)] + [InlineData(UnitWithProrationCadence.OneTime)] + [InlineData(UnitWithProrationCadence.Custom)] + public void Validation_Works(UnitWithProrationCadence 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(UnitWithProrationCadence.Annual)] + [InlineData(UnitWithProrationCadence.SemiAnnual)] + [InlineData(UnitWithProrationCadence.Monthly)] + [InlineData(UnitWithProrationCadence.Quarterly)] + [InlineData(UnitWithProrationCadence.OneTime)] + [InlineData(UnitWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(UnitWithProrationCadence 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 UnitWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + UnitWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationConfig { 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 UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + UnitWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + UnitWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + UnitWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + UnitWithProrationConversionRateConfig 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() + { + UnitWithProrationConversionRateConfig 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 GroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = GroupedAllocationCadence.Annual; + GroupedAllocationConfig expectedGroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + GroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, model.GroupedAllocationConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = GroupedAllocationCadence.Annual; + GroupedAllocationConfig expectedGroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + GroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, deserialized.GroupedAllocationConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedAllocationCadence.Annual)] + [InlineData(GroupedAllocationCadence.SemiAnnual)] + [InlineData(GroupedAllocationCadence.Monthly)] + [InlineData(GroupedAllocationCadence.Quarterly)] + [InlineData(GroupedAllocationCadence.OneTime)] + [InlineData(GroupedAllocationCadence.Custom)] + public void Validation_Works(GroupedAllocationCadence 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(GroupedAllocationCadence.Annual)] + [InlineData(GroupedAllocationCadence.SemiAnnual)] + [InlineData(GroupedAllocationCadence.Monthly)] + [InlineData(GroupedAllocationCadence.Quarterly)] + [InlineData(GroupedAllocationCadence.OneTime)] + [InlineData(GroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedAllocationCadence 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 GroupedAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedOverageUnitRate, model.OverageUnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_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 GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedOverageUnitRate, deserialized.OverageUnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + GroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedAllocationConversionRateConfig 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() + { + GroupedAllocationConversionRateConfig 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 BulkWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + BulkWithProrationConfig expectedBulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum expectedCadence = BulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + BulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, model.BulkWithProrationConfig); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + BulkWithProrationConfig expectedBulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum expectedCadence = BulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + BulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, deserialized.BulkWithProrationConfig); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + BulkWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithProrationConfig + { + 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 BulkWithProrationConfig + { + 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 expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + BulkWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(BulkWithProrationCadence.Annual)] + [InlineData(BulkWithProrationCadence.SemiAnnual)] + [InlineData(BulkWithProrationCadence.Monthly)] + [InlineData(BulkWithProrationCadence.Quarterly)] + [InlineData(BulkWithProrationCadence.OneTime)] + [InlineData(BulkWithProrationCadence.Custom)] + public void Validation_Works(BulkWithProrationCadence 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(BulkWithProrationCadence.Annual)] + [InlineData(BulkWithProrationCadence.SemiAnnual)] + [InlineData(BulkWithProrationCadence.Monthly)] + [InlineData(BulkWithProrationCadence.Quarterly)] + [InlineData(BulkWithProrationCadence.OneTime)] + [InlineData(BulkWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(BulkWithProrationCadence 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 BulkWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + BulkWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + BulkWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithProrationConversionRateConfig 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() + { + BulkWithProrationConversionRateConfig 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 GroupedWithProratedMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithProratedMinimumCadence.Annual; + GroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + GroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + model.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithProratedMinimumCadence.Annual; + GroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + GroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + deserialized.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithProratedMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithProratedMinimumCadence.Annual)] + [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithProratedMinimumCadence.Monthly)] + [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(GroupedWithProratedMinimumCadence.OneTime)] + [InlineData(GroupedWithProratedMinimumCadence.Custom)] + public void Validation_Works(GroupedWithProratedMinimumCadence 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(GroupedWithProratedMinimumCadence.Annual)] + [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithProratedMinimumCadence.Monthly)] + [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(GroupedWithProratedMinimumCadence.OneTime)] + [InlineData(GroupedWithProratedMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithProratedMinimumCadence 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 GroupedWithProratedMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimum, model.Minimum); + Assert.Equal(expectedUnitRate, model.UnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "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 GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimum, deserialized.Minimum); + Assert.Equal(expectedUnitRate, deserialized.UnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + GroupedWithProratedMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithProratedMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithProratedMinimumConversionRateConfig 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() + { + GroupedWithProratedMinimumConversionRateConfig 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 GroupedWithMeteredMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithMeteredMinimumCadence.Annual; + GroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + GroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + model.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithMeteredMinimumCadence.Annual; + GroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + GroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + deserialized.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithMeteredMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMeteredMinimumCadence.Annual)] + [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(GroupedWithMeteredMinimumCadence.Custom)] + public void Validation_Works(GroupedWithMeteredMinimumCadence 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(GroupedWithMeteredMinimumCadence.Annual)] + [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(GroupedWithMeteredMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumCadence 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 GroupedWithMeteredMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, model.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, model.PricingKey); + Assert.Equal(expectedScalingFactors.Count, model.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], model.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, model.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + 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 GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, deserialized.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, deserialized.PricingKey); + Assert.Equal(expectedScalingFactors.Count, deserialized.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], deserialized.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, deserialized.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + GroupedWithMeteredMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string expectedScalingFactorValue = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactorValue, model.ScalingFactorValue); + Assert.Equal(expectedScalingValue, model.ScalingValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + 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 ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedScalingFactorValue = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactorValue, deserialized.ScalingFactorValue); + Assert.Equal(expectedScalingValue, deserialized.ScalingValue); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + ScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmountValue = "unit_amount"; + + Assert.Equal(expectedPricingValue, model.PricingValue); + Assert.Equal(expectedUnitAmountValue, model.UnitAmountValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "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 UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmountValue = "unit_amount"; + + Assert.Equal(expectedPricingValue, deserialized.PricingValue); + Assert.Equal(expectedUnitAmountValue, deserialized.UnitAmountValue); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + UnitAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithMeteredMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithMeteredMinimumConversionRateConfig 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() + { + GroupedWithMeteredMinimumConversionRateConfig 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 GroupedWithMinMaxThresholdsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithMinMaxThresholdsCadence.Annual; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + GroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithMinMaxThresholdsCadence.Annual; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + GroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(GroupedWithMinMaxThresholdsCadence 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(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence 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 GroupedWithMinMaxThresholdsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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() + { + var model = new 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 + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new 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 + ); + 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 GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithMinMaxThresholdsLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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 MatrixWithDisplayNameTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + MatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, model.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + MatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, deserialized.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MatrixWithDisplayName copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithDisplayNameCadence.Annual)] + [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(MatrixWithDisplayNameCadence.Monthly)] + [InlineData(MatrixWithDisplayNameCadence.Quarterly)] + [InlineData(MatrixWithDisplayNameCadence.OneTime)] + [InlineData(MatrixWithDisplayNameCadence.Custom)] + public void Validation_Works(MatrixWithDisplayNameCadence 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(MatrixWithDisplayNameCadence.Annual)] + [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(MatrixWithDisplayNameCadence.Monthly)] + [InlineData(MatrixWithDisplayNameCadence.Quarterly)] + [InlineData(MatrixWithDisplayNameCadence.OneTime)] + [InlineData(MatrixWithDisplayNameCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithDisplayNameCadence 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 MatrixWithDisplayNameLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MatrixWithDisplayNameLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, model.Dimension); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, deserialized.Dimension); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + MatrixWithDisplayNameConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConfigUnitAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, model.DimensionValue); + Assert.Equal(expectedDisplayName, model.DisplayName); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, deserialized.DimensionValue); + Assert.Equal(expectedDisplayName, deserialized.DisplayName); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + MatrixWithDisplayNameConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithDisplayNameConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithDisplayNameConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithDisplayNameConversionRateConfig 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() + { + MatrixWithDisplayNameConversionRateConfig 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 GroupedTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedTieredPackageCadence.Annual; + GroupedTieredPackageConfig expectedGroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + GroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, model.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedTieredPackageCadence.Annual; + GroupedTieredPackageConfig expectedGroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + GroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, deserialized.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedTieredPackageCadence.Annual)] + [InlineData(GroupedTieredPackageCadence.SemiAnnual)] + [InlineData(GroupedTieredPackageCadence.Monthly)] + [InlineData(GroupedTieredPackageCadence.Quarterly)] + [InlineData(GroupedTieredPackageCadence.OneTime)] + [InlineData(GroupedTieredPackageCadence.Custom)] + public void Validation_Works(GroupedTieredPackageCadence 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(GroupedTieredPackageCadence.Annual)] + [InlineData(GroupedTieredPackageCadence.SemiAnnual)] + [InlineData(GroupedTieredPackageCadence.Monthly)] + [InlineData(GroupedTieredPackageCadence.Quarterly)] + [InlineData(GroupedTieredPackageCadence.OneTime)] + [InlineData(GroupedTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedTieredPackageCadence 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 GroupedTieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + GroupedTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + 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 GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + GroupedTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedTieredPackageConversionRateConfig 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() + { + GroupedTieredPackageConversionRateConfig 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 MaxGroupTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + MaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, model.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + MaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, deserialized.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MaxGroupTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(MaxGroupTieredPackageCadence.Annual)] + [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(MaxGroupTieredPackageCadence.Monthly)] + [InlineData(MaxGroupTieredPackageCadence.Quarterly)] + [InlineData(MaxGroupTieredPackageCadence.OneTime)] + [InlineData(MaxGroupTieredPackageCadence.Custom)] + public void Validation_Works(MaxGroupTieredPackageCadence 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(MaxGroupTieredPackageCadence.Annual)] + [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(MaxGroupTieredPackageCadence.Monthly)] + [InlineData(MaxGroupTieredPackageCadence.Quarterly)] + [InlineData(MaxGroupTieredPackageCadence.OneTime)] + [InlineData(MaxGroupTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(MaxGroupTieredPackageCadence 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 MaxGroupTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MaxGroupTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + MaxGroupTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + MaxGroupTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MaxGroupTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MaxGroupTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MaxGroupTieredPackageConversionRateConfig 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() + { + MaxGroupTieredPackageConversionRateConfig 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 ScalableMatrixWithUnitPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + model.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + deserialized.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] + public void Validation_Works(ScalableMatrixWithUnitPricingCadence 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(ScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] + public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingCadence 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 ScalableMatrixWithUnitPricingLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ScalableMatrixWithUnitPricingLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedProrate, model.Prorate); + Assert.Equal(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + 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 ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedProrate, deserialized.Prorate); + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + MatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig 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() + { + ScalableMatrixWithUnitPricingConversionRateConfig 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 ScalableMatrixWithTieredPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + model.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + deserialized.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] + public void Validation_Works(ScalableMatrixWithTieredPricingCadence 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(ScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] + public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingCadence 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 ScalableMatrixWithTieredPricingLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ScalableMatrixWithTieredPricingLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[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(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + 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 ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[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(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + ScalableMatrixWithTieredPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ScalableMatrixWithTieredPricingConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig 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() + { + ScalableMatrixWithTieredPricingConversionRateConfig 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 CumulativeGroupedBulkTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + CumulativeGroupedBulkCadence.Annual; + CumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + CumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, model.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + CumulativeGroupedBulkCadence.Annual; + CumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + CumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, deserialized.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + CumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkCadenceTest : TestBase +{ + [Theory] + [InlineData(CumulativeGroupedBulkCadence.Annual)] + [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(CumulativeGroupedBulkCadence.Monthly)] + [InlineData(CumulativeGroupedBulkCadence.Quarterly)] + [InlineData(CumulativeGroupedBulkCadence.OneTime)] + [InlineData(CumulativeGroupedBulkCadence.Custom)] + public void Validation_Works(CumulativeGroupedBulkCadence 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(CumulativeGroupedBulkCadence.Annual)] + [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(CumulativeGroupedBulkCadence.Monthly)] + [InlineData(CumulativeGroupedBulkCadence.Quarterly)] + [InlineData(CumulativeGroupedBulkCadence.OneTime)] + [InlineData(CumulativeGroupedBulkCadence.Custom)] + public void SerializationRoundtrip_Works(CumulativeGroupedBulkCadence 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 CumulativeGroupedBulkConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } + Assert.Equal(expectedGroup, model.Group); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + 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 CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } + Assert.Equal(expectedGroup, deserialized.Group); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + CumulativeGroupedBulkConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DimensionValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + 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 DimensionValue + { + GroupingKey = "x", + 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 expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + DimensionValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + CumulativeGroupedBulkLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + CumulativeGroupedBulkConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + CumulativeGroupedBulkConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + CumulativeGroupedBulkConversionRateConfig 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() + { + CumulativeGroupedBulkConversionRateConfig 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 CumulativeGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + CumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + CumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [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.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + CumulativeGroupedAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + CumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + CumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + CumulativeGroupedAllocationConversionRateConfig 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() + { + CumulativeGroupedAllocationConversionRateConfig 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 MinimumCompositeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = MinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MinimumCompositeConfig expectedMinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + MinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, model.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 = MinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MinimumCompositeConfig expectedMinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + MinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, deserialized.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MinimumComposite copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeCadenceTest : TestBase +{ + [Theory] + [InlineData(MinimumCompositeCadence.Annual)] + [InlineData(MinimumCompositeCadence.SemiAnnual)] + [InlineData(MinimumCompositeCadence.Monthly)] + [InlineData(MinimumCompositeCadence.Quarterly)] + [InlineData(MinimumCompositeCadence.OneTime)] + [InlineData(MinimumCompositeCadence.Custom)] + public void Validation_Works(MinimumCompositeCadence 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(MinimumCompositeCadence.Annual)] + [InlineData(MinimumCompositeCadence.SemiAnnual)] + [InlineData(MinimumCompositeCadence.Monthly)] + [InlineData(MinimumCompositeCadence.Quarterly)] + [InlineData(MinimumCompositeCadence.OneTime)] + [InlineData(MinimumCompositeCadence.Custom)] + public void SerializationRoundtrip_Works(MinimumCompositeCadence 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 MinimumCompositeLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MinimumCompositeLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumCompositeConfig { MinimumAmount = "minimum_amount" }; + + Assert.Null(model.Prorated); + Assert.False(model.RawData.ContainsKey("prorated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new MinimumCompositeConfig { MinimumAmount = "minimum_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + + // Null should be interpreted as omitted for these properties + Prorated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + MinimumCompositeConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MinimumCompositeConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MinimumCompositeConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MinimumCompositeConversionRateConfig 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() + { + MinimumCompositeConversionRateConfig 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] + public void FieldRoundtrip_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = PercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 = PercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentCadenceTest : 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) + { + // 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(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; + + 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 PercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PercentLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PercentLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + PercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PercentConfig { Percent = 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 PercentConfig { Percent = 0 }; + + 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 Validation_Works() + { + var model = new PercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PercentConversionRateConfig 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() + { + PercentConversionRateConfig 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 EventOutputTest : 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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } +} + +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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new EventOutputConfig + { + 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 EventOutputConfig + { + 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 EventOutputConfig + { + 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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EventOutputLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new EventOutputLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new EventOutputLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + EventOutputLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + EventOutputConversionRateConfig 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() + { + EventOutputConversionRateConfig 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 PriceTest : TestBase +{ + [Fact] + public void NewPlanUnitValidationWorks() + { + Price value = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanTieredValidationWorks() + { + Price value = new Models::NewPlanTieredPrice() + { + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanBulkValidationWorks() + { + Price value = new Models::NewPlanBulkPrice() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanBulkPriceModelType.Bulk, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithFiltersValidationWorks() + { + Price value = new PriceBulkWithFilters() + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanPackageValidationWorks() + { + Price value = new Models::NewPlanPackagePrice() + { + Cadence = Models::NewPlanPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMatrixValidationWorks() + { + Price value = new Models::NewPlanMatrixPrice() + { + Cadence = Models::NewPlanMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanThresholdTotalAmountValidationWorks() + { + Price value = new Models::NewPlanThresholdTotalAmountPrice() + { + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanTieredPackageValidationWorks() + { + Price value = new Models::NewPlanTieredPackagePrice() + { + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPackagePriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanTieredWithMinimumValidationWorks() + { + Price value = new Models::NewPlanTieredWithMinimumPrice() + { + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedTieredValidationWorks() + { + Price value = new Models::NewPlanGroupedTieredPrice() + { + Cadence = Models::NewPlanGroupedTieredPriceCadence.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 = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanTieredPackageWithMinimumValidationWorks() + { + Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + { + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanTieredPackageWithMinimumPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanPackageWithAllocationValidationWorks() + { + Price value = new Models::NewPlanPackageWithAllocationPrice() + { + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackageWithAllocationPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitWithPercentValidationWorks() + { + Price value = new Models::NewPlanUnitWithPercentPrice() + { + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMatrixWithAllocationValidationWorks() + { + Price value = new Models::NewPlanMatrixWithAllocationPrice() + { + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredWithProrationValidationWorks() + { + Price value = new PriceTieredWithProration() + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitWithProrationValidationWorks() + { + Price value = new Models::NewPlanUnitWithProrationPrice() + { + Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedAllocationValidationWorks() + { + Price value = new Models::NewPlanGroupedAllocationPrice() + { + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanBulkWithProrationValidationWorks() + { + Price value = new Models::NewPlanBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedWithProratedMinimumValidationWorks() + { + Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + { + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedWithMeteredMinimumValidationWorks() + { + Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + { + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMinMaxThresholdsValidationWorks() + { + Price value = new PriceGroupedWithMinMaxThresholds() + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMatrixWithDisplayNameValidationWorks() + { + Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + { + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanGroupedTieredPackageValidationWorks() + { + Price value = new Models::NewPlanGroupedTieredPackagePrice() + { + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.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 = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMaxGroupTieredPackageValidationWorks() + { + Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + { + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.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 = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + { + Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + { + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + { + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + { + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanCumulativeGroupedBulkValidationWorks() + { + Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + { + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedAllocationValidationWorks() + { + Price value = new PriceCumulativeGroupedAllocation() + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMinimumCompositeValidationWorks() + { + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PercentValidationWorks() + { + Price value = new PricePercent() + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + Price value = new PriceEventOutput() + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitSerializationRoundtripWorks() + { + Price value = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanTieredSerializationRoundtripWorks() + { + Price value = new Models::NewPlanTieredPrice() + { + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanBulkSerializationRoundtripWorks() + { + Price value = new Models::NewPlanBulkPrice() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanBulkPriceModelType.Bulk, + 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithFiltersSerializationRoundtripWorks() + { + Price value = new PriceBulkWithFilters() + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanPackageSerializationRoundtripWorks() + { + Price value = new Models::NewPlanPackagePrice() + { + Cadence = Models::NewPlanPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanMatrixSerializationRoundtripWorks() + { + Price value = new Models::NewPlanMatrixPrice() + { + Cadence = Models::NewPlanMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + { + Price value = new Models::NewPlanThresholdTotalAmountPrice() + { + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanTieredPackageSerializationRoundtripWorks() + { + Price value = new Models::NewPlanTieredPackagePrice() + { + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPackagePriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + { + Price value = new Models::NewPlanTieredWithMinimumPrice() + { + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedTieredSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedTieredPrice() + { + Cadence = Models::NewPlanGroupedTieredPriceCadence.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 = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + { + Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + { + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanTieredPackageWithMinimumPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanPackageWithAllocationPrice() + { + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackageWithAllocationPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanUnitWithPercentSerializationRoundtripWorks() + { + Price value = new Models::NewPlanUnitWithPercentPrice() + { + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanMatrixWithAllocationPrice() + { + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProrationSerializationRoundtripWorks() + { + Price value = new PriceTieredWithProration() + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanUnitWithProrationPrice() + { + Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedAllocationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedAllocationPrice() + { + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanBulkWithProrationSerializationRoundtripWorks() + { + Price value = new Models::NewPlanBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + { + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + { + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + Price value = new PriceGroupedWithMinMaxThresholds() + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + { + Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + { + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() + { + Price value = new Models::NewPlanGroupedTieredPackagePrice() + { + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.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 = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + { + Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + { + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.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 = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + { + Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + { + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + { + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + { + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + { + Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + { + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + { + Price value = new PriceCumulativeGroupedAllocation() + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + 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() + { + 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + Price value = new PricePercent() + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + 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() + { + Price value = new PriceEventOutput() + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PriceBulkWithFiltersTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceBulkWithFiltersBulkWithFiltersConfig 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 = + PriceBulkWithFiltersCadence.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; + PriceBulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + 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); + + PriceBulkWithFiltersBulkWithFiltersConfig 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 = + PriceBulkWithFiltersCadence.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; + PriceBulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFilters + { + 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 = PriceBulkWithFiltersCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PriceBulkWithFiltersBulkWithFiltersConfig + { + 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + PriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + PriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + PriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceBulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceBulkWithFiltersCadence.Annual)] + [InlineData(PriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(PriceBulkWithFiltersCadence.Monthly)] + [InlineData(PriceBulkWithFiltersCadence.Quarterly)] + [InlineData(PriceBulkWithFiltersCadence.OneTime)] + [InlineData(PriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(PriceBulkWithFiltersCadence 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(PriceBulkWithFiltersCadence.Annual)] + [InlineData(PriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(PriceBulkWithFiltersCadence.Monthly)] + [InlineData(PriceBulkWithFiltersCadence.Quarterly)] + [InlineData(PriceBulkWithFiltersCadence.OneTime)] + [InlineData(PriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works(PriceBulkWithFiltersCadence 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 PriceBulkWithFiltersConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceBulkWithFiltersConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceBulkWithFiltersConversionRateConfig 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() + { + PriceBulkWithFiltersConversionRateConfig 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 PriceTieredWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + PriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceTieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + PriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + PriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceTieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceTieredWithProration + { + Cadence = PriceTieredWithProrationCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceTieredWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceTieredWithProrationCadence.Annual)] + [InlineData(PriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(PriceTieredWithProrationCadence.Monthly)] + [InlineData(PriceTieredWithProrationCadence.Quarterly)] + [InlineData(PriceTieredWithProrationCadence.OneTime)] + [InlineData(PriceTieredWithProrationCadence.Custom)] + public void Validation_Works(PriceTieredWithProrationCadence 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(PriceTieredWithProrationCadence.Annual)] + [InlineData(PriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(PriceTieredWithProrationCadence.Monthly)] + [InlineData(PriceTieredWithProrationCadence.Quarterly)] + [InlineData(PriceTieredWithProrationCadence.OneTime)] + [InlineData(PriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(PriceTieredWithProrationCadence 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 PriceTieredWithProrationTieredWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceTieredWithProrationTieredWithProrationConfig + { + 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 PriceTieredWithProrationTieredWithProrationConfig + { + 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 PriceTieredWithProrationTieredWithProrationConfig + { + 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 PriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + PriceTieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + PriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceTieredWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceTieredWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceTieredWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceTieredWithProrationConversionRateConfig 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() + { + PriceTieredWithProrationConversionRateConfig 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 PriceGroupedWithMinMaxThresholdsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PriceGroupedWithMinMaxThresholdsCadence.Annual; + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + PriceGroupedWithMinMaxThresholdsCadence.Annual; + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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")); + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(PriceGroupedWithMinMaxThresholdsCadence 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(PriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(PriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works(PriceGroupedWithMinMaxThresholdsCadence 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceGroupedWithMinMaxThresholdsConversionRateConfig 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() + { + PriceGroupedWithMinMaxThresholdsConversionRateConfig 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 PriceCumulativeGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PriceCumulativeGroupedAllocationCadence.Annual; + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + PriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + 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(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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 = + PriceCumulativeGroupedAllocationCadence.Annual; + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + PriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + 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(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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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")); + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceCumulativeGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(PriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(PriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(PriceCumulativeGroupedAllocationCadence 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(PriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(PriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(PriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(PriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(PriceCumulativeGroupedAllocationCadence 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceCumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceCumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceCumulativeGroupedAllocationConversionRateConfig 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() + { + PriceCumulativeGroupedAllocationConversionRateConfig 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] + public void FieldRoundtrip_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = PricePercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + PricePercentPercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PricePercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 = PricePercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + PricePercentPercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PricePercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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(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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PricePercent + { + Cadence = PricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PricePercent + { + Cadence = PricePercentCadence.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePercent + { + Cadence = PricePercentCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PricePercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePercentCadenceTest : TestBase +{ + [Theory] + [InlineData(PricePercentCadence.Annual)] + [InlineData(PricePercentCadence.SemiAnnual)] + [InlineData(PricePercentCadence.Monthly)] + [InlineData(PricePercentCadence.Quarterly)] + [InlineData(PricePercentCadence.OneTime)] + [InlineData(PricePercentCadence.Custom)] + public void Validation_Works(PricePercentCadence 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(PricePercentCadence.Annual)] + [InlineData(PricePercentCadence.SemiAnnual)] + [InlineData(PricePercentCadence.Monthly)] + [InlineData(PricePercentCadence.Quarterly)] + [InlineData(PricePercentCadence.OneTime)] + [InlineData(PricePercentCadence.Custom)] + public void SerializationRoundtrip_Works(PricePercentCadence 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 PricePercentPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PricePercentPercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PricePercentPercentConfig { Percent = 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 PricePercentPercentConfig { Percent = 0 }; + + 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 Validation_Works() + { + var model = new PricePercentPercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePercentPercentConfig { Percent = 0 }; + + PricePercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PricePercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PricePercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PricePercentConversionRateConfig 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() + { + PricePercentConversionRateConfig 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 PriceEventOutputTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = PriceEventOutputCadence.Annual; + PriceEventOutputEventOutputConfig 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; + PriceEventOutputConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + 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 = PriceEventOutputCadence.Annual; + PriceEventOutputEventOutputConfig 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; + PriceEventOutputConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PriceEventOutput + { + Cadence = PriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEventOutput + { + Cadence = PriceEventOutputCadence.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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEventOutputCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceEventOutputCadence.Annual)] + [InlineData(PriceEventOutputCadence.SemiAnnual)] + [InlineData(PriceEventOutputCadence.Monthly)] + [InlineData(PriceEventOutputCadence.Quarterly)] + [InlineData(PriceEventOutputCadence.OneTime)] + [InlineData(PriceEventOutputCadence.Custom)] + public void Validation_Works(PriceEventOutputCadence 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(PriceEventOutputCadence.Annual)] + [InlineData(PriceEventOutputCadence.SemiAnnual)] + [InlineData(PriceEventOutputCadence.Monthly)] + [InlineData(PriceEventOutputCadence.Quarterly)] + [InlineData(PriceEventOutputCadence.OneTime)] + [InlineData(PriceEventOutputCadence.Custom)] + public void SerializationRoundtrip_Works(PriceEventOutputCadence 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 PriceEventOutputEventOutputConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceEventOutputEventOutputConfig + { + 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 PriceEventOutputEventOutputConfig + { + 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 PriceEventOutputEventOutputConfig + { + 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 PriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceEventOutputEventOutputConfig { 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 PriceEventOutputEventOutputConfig { UnitRatingKey = "x" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceEventOutputEventOutputConfig + { + 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 PriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + PriceEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceEventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceEventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceEventOutputConversionRateConfig 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() + { + PriceEventOutputConversionRateConfig 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 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( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAdjustmentID = "adjustment_id"; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + } + + [Fact] + public void Validation_Works() + { + var model = new RemoveAdjustment { AdjustmentID = "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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + + RemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); + } +} + +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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + + RemovePrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplaceAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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 = 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); + } + + [Fact] + public void SerializationRoundtrip_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 = 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 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( + 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, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + } + + [Fact] + public void Validation_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 = 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", + }; + + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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", + }; + + 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(); + } + + [Fact] + public void CopyConstructor_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 = 0, + }; + + ReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ + [Fact] + public void NewPercentageDiscountValidationWorks() + { + ReplaceAdjustmentAdjustment value = 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, + }; + value.Validate(); + } + + [Fact] + public void NewUsageDiscountValidationWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + { + AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewUsageDiscountFilterField.PriceID, + Operator = Models::NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewUsageDiscountPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewAmountDiscountValidationWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + { + AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = Models::AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewAmountDiscountFilterField.PriceID, + Operator = Models::NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::PriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewMinimumValidationWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + { + AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = Models::NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewMinimumFilterField.PriceID, + Operator = Models::NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewMinimumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewMaximumValidationWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + { + AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = Models::NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewMaximumFilterField.PriceID, + Operator = Models::NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewMaximumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewPercentageDiscountSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = 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 element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewUsageDiscountSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + { + AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewUsageDiscountFilterField.PriceID, + Operator = Models::NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewUsageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewAmountDiscountSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + { + AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = Models::AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewAmountDiscountFilterField.PriceID, + Operator = Models::NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::PriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewMinimumSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + { + AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = Models::NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewMinimumFilterField.PriceID, + Operator = Models::NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewMinimumPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewMaximumSerializationRoundtripWorks() + { + ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + { + AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = Models::NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewMaximumFilterField.PriceID, + Operator = Models::NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::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 FieldRoundtrip_Works() + { + var model = new ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }; + + string expectedReplacesPriceID = "replaces_price_id"; + Models::NewAllocationPrice expectedAllocationPrice = 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + ReplacePriceLicenseAllocationPrice expectedLicenseAllocationPrice = + new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + long expectedPlanPhaseOrder = 0; + ReplacePricePrice expectedPrice = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, model.LicenseAllocationPrice); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedPrice, model.Price); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 expectedReplacesPriceID = "replaces_price_id"; + Models::NewAllocationPrice expectedAllocationPrice = 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + ReplacePriceLicenseAllocationPrice expectedLicenseAllocationPrice = + new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + long expectedPlanPhaseOrder = 0; + ReplacePricePrice expectedPrice = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, deserialized.LicenseAllocationPrice); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedPrice, deserialized.Price); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.False(model.RawData.ContainsKey("license_allocation_price")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.False(model.RawData.ContainsKey("price")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, + }; + + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.True(model.RawData.ContainsKey("license_allocation_price")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.True(model.RawData.ContainsKey("price")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePrice + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }; + + ReplacePrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceTiered() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceBulk() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithFiltersValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceBulkWithFilters() + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PackageValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPricePackage() + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceMatrix() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ThresholdTotalAmountValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmount() + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredPackageValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredWithMinimumValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredWithMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedTieredValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedTiered() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredPackageWithMinimumValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PackageWithAllocationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPricePackageWithAllocation() + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitWithPercentValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceUnitWithPercent() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithAllocationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMatrixWithAllocation() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredWithProrationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredWithProration() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitWithProrationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceUnitWithProration() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedAllocationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedAllocation() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithProrationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceBulkWithProration() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithProratedMinimumValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum() + { + Cadence = + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMeteredMinimumValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMinMaxThresholdsValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds() + { + Cadence = + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithDisplayNameValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedTieredPackageValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MaxGroupTieredPackageValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ScalableMatrixWithUnitPricingValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing() + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ScalableMatrixWithTieredPricingValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing() + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedBulkValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk() + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedAllocationValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation() + { + Cadence = + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MinimumCompositeValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMinimumComposite() + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PercentValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPricePercent() + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceEventOutput() + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceUnit() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceTiered() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceBulk() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithFiltersSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceBulkWithFilters() + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPricePackage() + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPriceMatrix() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ThresholdTotalAmountSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmount() + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithMinimumSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredWithMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedTiered() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageWithMinimumSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageWithAllocationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPricePackageWithAllocation() + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithPercentSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceUnitWithPercent() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithAllocationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMatrixWithAllocation() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProrationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceTieredWithProration() + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithProrationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceUnitWithProration() + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedAllocationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedAllocation() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithProrationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceBulkWithProration() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithProratedMinimumSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum() + { + Cadence = + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMeteredMinimumSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds() + { + Cadence = + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithDisplayNameSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName() + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredPackageSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MaxGroupTieredPackageSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage() + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithUnitPricingSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing() + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithTieredPricingSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing() + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedBulkSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk() + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation() + { + Cadence = + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MinimumCompositeSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceMinimumComposite() + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + ReplacePriceLicenseAllocationPrice value = new ReplacePriceLicenseAllocationPricePercent() + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + ReplacePriceLicenseAllocationPrice value = + new ReplacePriceLicenseAllocationPriceEventOutput() + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceUnitTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceUnitCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitConfig, model.UnitConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceUnitCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitConfig, deserialized.UnitConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnit + { + Cadence = ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceUnit copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceUnitCadence 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(ReplacePriceLicenseAllocationPriceUnitCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceUnitCadence 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 ReplacePriceLicenseAllocationPriceUnitLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceUnitLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceTieredCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); + string expectedName = "Annual fee"; + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredConfig, model.TieredConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceTieredCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); + string expectedName = "Annual fee"; + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredConfig, deserialized.TieredConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTiered + { + Cadence = ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTiered copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceTieredCadence 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(ReplacePriceLicenseAllocationPriceTieredCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredCadence 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 ReplacePriceLicenseAllocationPriceTieredLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig 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 ReplacePriceLicenseAllocationPriceBulkTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] + ); + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceBulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); + 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; + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkConfig, model.BulkConfig); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] + ); + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceBulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); + 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; + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkConfig, deserialized.BulkConfig); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulk copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceBulkCadence 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(ReplacePriceLicenseAllocationPriceBulkCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceBulkCadence 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 ReplacePriceLicenseAllocationPriceBulkLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceBulkLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig 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 = + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig 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 = + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFilters + { + 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 = ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilterTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence 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(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig 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 ReplacePriceLicenseAllocationPricePackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPricePackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); + string expectedName = "Annual fee"; + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPackageConfig, model.PackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPricePackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); + string expectedName = "Annual fee"; + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPackageConfig, deserialized.PackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackage + { + Cadence = ReplacePriceLicenseAllocationPricePackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPricePackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPricePackageCadence 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(ReplacePriceLicenseAllocationPricePackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePackageCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPricePackageCadence 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 ReplacePriceLicenseAllocationPricePackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPricePackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPricePackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPricePackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPricePackageConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPricePackageConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMatrixTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceMatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); + 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; + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, model.MatrixConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceMatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); + 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; + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, deserialized.MatrixConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrix + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMatrix copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceMatrixCadence 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(ReplacePriceLicenseAllocationPriceMatrixCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMatrixCadence 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 ReplacePriceLicenseAllocationPriceMatrixLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = + new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, model.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = + new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, deserialized.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmount + { + Cadence = ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceThresholdTotalAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence 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(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; + + Assert.Equal(expectedConsumptionTable.Count, model.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], model.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, model.Prorate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; + + Assert.Equal(expectedConsumptionTable.Count, deserialized.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], deserialized.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, deserialized.Prorate); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + }; + + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + + Prorate = null, + }; + + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + + Prorate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTableTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, model.Threshold); + Assert.Equal(expectedTotalAmount, model.TotalAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, deserialized.Threshold); + Assert.Equal(expectedTotalAmount, deserialized.TotalAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + { + Threshold = "threshold", + TotalAmount = "total_amount", + }; + + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig expectedTieredPackageConfig = + new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageConfig, model.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig expectedTieredPackageConfig = + new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredPackageConfig, deserialized.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceTieredPackageCadence 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(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredPackageCadence 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 ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + 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 ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig expectedTieredWithMinimumConfig = + 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithMinimumConfig, model.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig expectedTieredWithMinimumConfig = + 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithMinimumConfig, deserialized.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTieredWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence 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(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, model.HideZeroAmountTiers); + Assert.Equal(expectedProrate, model.Prorate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, deserialized.HideZeroAmountTiers); + Assert.Equal(expectedProrate, deserialized.Prorate); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + { + 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, + }; + + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedTieredTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig expectedGroupedTieredConfig = + new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredConfig, model.GroupedTieredConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig expectedGroupedTieredConfig = + new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredConfig, deserialized.GroupedTieredConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTiered + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedTiered copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceGroupedTieredCadence 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(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedTieredCadence 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + 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 ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = + 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageWithMinimumConfig, model.TieredPackageWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = + 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedTieredPackageWithMinimumConfig, + deserialized.TieredPackageWithMinimumConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence 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(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig 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 ReplacePriceLicenseAllocationPricePackageWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig expectedPackageWithAllocationConfig = + new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPackageWithAllocationConfig, model.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig expectedPackageWithAllocationConfig = + new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPackageWithAllocationConfig, deserialized.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPricePackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence 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(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence 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 ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedPackageAmount, model.PackageAmount); + Assert.Equal(expectedPackageSize, model.PackageSize); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + 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 ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedPackageAmount, deserialized.PackageAmount); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceUnitWithPercentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig expectedUnitWithPercentConfig = + new() { Percent = "percent", UnitAmount = "unit_amount" }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithPercentConfig, model.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig expectedUnitWithPercentConfig = + new() { Percent = "percent", UnitAmount = "unit_amount" }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithPercentConfig, deserialized.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercent + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceUnitWithPercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithPercentCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence 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(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence 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 ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + 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 ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, model.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, deserialized.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMatrixWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence 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(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence 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(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence 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 ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceUnitWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig expectedUnitWithProrationConfig = + new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig expectedUnitWithProrationConfig = + new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithProrationConfig, deserialized.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProration + { + Cadence = ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceUnitWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence 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(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence 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 ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + { + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig expectedGroupedAllocationConfig = + new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, model.GroupedAllocationConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig expectedGroupedAllocationConfig = + new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, deserialized.GroupedAllocationConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence 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(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence 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 ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedOverageUnitRate, model.OverageUnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_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 ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedOverageUnitRate, deserialized.OverageUnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceBulkWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig expectedBulkWithProrationConfig = + new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, model.BulkWithProrationConfig); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig expectedBulkWithProrationConfig = + new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, deserialized.BulkWithProrationConfig); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceBulkWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + 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 expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence 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(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence 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 ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = + new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + model.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = + new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + deserialized.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence 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(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimum, model.Minimum); + Assert.Equal(expectedUnitRate, model.UnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimum, deserialized.Minimum); + Assert.Equal(expectedUnitRate, deserialized.UnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = + 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + model.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = + 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + deserialized.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + 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" }, + ], + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence 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(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, model.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, model.PricingKey); + Assert.Equal(expectedScalingFactors.Count, model.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], model.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, model.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, deserialized.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, deserialized.PricingKey); + Assert.Equal(expectedScalingFactors.Count, deserialized.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], deserialized.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, deserialized.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string expectedScalingFactor = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedScalingValue, model.ScalingValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedScalingFactor = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedScalingValue, deserialized.ScalingValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPricingValue, model.PricingValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPricingValue, deserialized.PricingValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > 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(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = + new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, model.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = + new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, deserialized.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayName + { + Cadence = ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence 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(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, model.Dimension); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, deserialized.Dimension); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, model.DimensionValue); + Assert.Equal(expectedDisplayName, model.DisplayName); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, deserialized.DimensionValue); + Assert.Equal(expectedDisplayName, deserialized.DisplayName); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig expectedGroupedTieredPackageConfig = + new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, model.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual; + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig expectedGroupedTieredPackageConfig = + new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, deserialized.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence 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(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = + new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, model.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = + new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, deserialized.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage + { + Cadence = ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence 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(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = + new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + model.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = + new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + deserialized.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + { + Cadence = ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > 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(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedProrate, model.Prorate); + Assert.Equal(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedProrate, deserialized.Prorate); + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = + 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + model.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = + 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + deserialized.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + { + Cadence = + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.SemiAnnual + )] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.SemiAnnual + )] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[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(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[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(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + 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", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual; + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = + new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, model.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence + > expectedCadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual; + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = + new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, deserialized.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence 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(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } + Assert.Equal(expectedGroup, model.Group); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } + Assert.Equal(expectedGroup, deserialized.Group); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + 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 expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual; + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > expectedCadence = + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual; + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation + { + Cadence = ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > 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(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig 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 ReplacePriceLicenseAllocationPriceMinimumCompositeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig expectedMinimumCompositeConfig = + new() { MinimumAmount = "minimum_amount", Prorated = true }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, model.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig expectedMinimumCompositeConfig = + new() { MinimumAmount = "minimum_amount", Prorated = true }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, deserialized.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumComposite + { + Cadence = ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceMinimumComposite copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMinimumCompositeCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence 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(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence 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 ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + }; + + Assert.Null(model.Prorated); + Assert.False(model.RawData.ContainsKey("prorated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + + // Null should be interpreted as omitted for these properties + Prorated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig 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 ReplacePriceLicenseAllocationPricePercentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPricePercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPricePercentPercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPricePercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + ReplacePriceLicenseAllocationPricePercentPercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPricePercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercent + { + Cadence = ReplacePriceLicenseAllocationPricePercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPricePercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePercentCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPricePercentCadence 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(ReplacePriceLicenseAllocationPricePercentCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPricePercentCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPricePercentCadence 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 ReplacePriceLicenseAllocationPricePercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPricePercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePercentPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 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 ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 0 }; + + 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 Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPricePercentPercentConfig { Percent = 0 }; + + ReplacePriceLicenseAllocationPricePercentPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPricePercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPricePercentConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPricePercentConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPricePercentConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPricePercentConversionRateConfig 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 ReplacePriceLicenseAllocationPriceEventOutputTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual; + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual; + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutput + { + Cadence = ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePriceLicenseAllocationPriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceEventOutputCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceEventOutputCadence 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(ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceEventOutputCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePriceLicenseAllocationPriceEventOutputCadence 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + 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 ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig 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() + { + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig 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 ReplacePricePriceTest : TestBase { [Fact] diff --git a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs index fc051e4ec..1c35b8942 100644 --- a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs @@ -45,6 +45,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -163,6 +211,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -317,6 +413,54 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -443,6 +587,54 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -572,6 +764,54 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -667,6 +907,54 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -769,12 +1057,60 @@ public void Url_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - PriceValue = new Models::NewPlanUnitPrice() + LicenseAllocationPrice = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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", @@ -854,6 +1190,54 @@ public void CopyConstructor_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -979,6 +1363,54 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -1046,6 +1478,53 @@ public void FieldRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; long expectedPlanPhaseOrder = 0; PricePrice expectedPriceValue = new Models::NewPlanUnitPrice() { @@ -1088,6 +1567,7 @@ public void FieldRoundtrip_Works() }; Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, model.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPriceValue, model.PriceValue); } @@ -1121,6 +1601,54 @@ public void SerializationRoundtrip_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -1199,12 +1727,19 @@ public void FieldRoundtripThroughSerialization_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - PriceValue = new Models::NewPlanUnitPrice() + LicenseAllocationPrice = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", @@ -1240,26 +1775,67 @@ 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); - - Models::NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + PlanPhaseOrder = 0, + PriceValue = new Models::NewPlanUnitPrice() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() + 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, + }, + LicenseTypeID = "license_type_id", + 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); + + Models::NewAllocationPrice expectedAllocationPrice = 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, @@ -1270,6 +1846,53 @@ public void FieldRoundtripThroughSerialization_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; long expectedPlanPhaseOrder = 0; PricePrice expectedPriceValue = new Models::NewPlanUnitPrice() { @@ -1312,6 +1935,7 @@ public void FieldRoundtripThroughSerialization_Works() }; Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, deserialized.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPriceValue, deserialized.PriceValue); } @@ -1345,6 +1969,54 @@ public void Validation_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -1392,132 +2064,40233 @@ public void Validation_Works() } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Price { }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.False(model.RawData.ContainsKey("license_allocation_price")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.PriceValue); + Assert.False(model.RawData.ContainsKey("price")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Price { }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Price + { + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + PriceValue = null, + }; + + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.LicenseAllocationPrice); + Assert.True(model.RawData.ContainsKey("license_allocation_price")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.PriceValue); + Assert.True(model.RawData.ContainsKey("price")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Price + { + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + PriceValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Price + { + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }; + + Price copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class LicenseAllocationPriceTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + LicenseAllocationPrice value = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + LicenseAllocationPrice value = new Tiered() + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkValidationWorks() + { + LicenseAllocationPrice value = new Bulk() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithFiltersValidationWorks() + { + LicenseAllocationPrice value = new 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PackageValidationWorks() + { + LicenseAllocationPrice value = new Package() + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixValidationWorks() + { + LicenseAllocationPrice value = new Matrix() + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ThresholdTotalAmountValidationWorks() + { + LicenseAllocationPrice value = new ThresholdTotalAmount() + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredPackageValidationWorks() + { + LicenseAllocationPrice value = new TieredPackage() + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredWithMinimumValidationWorks() + { + LicenseAllocationPrice value = new TieredWithMinimum() + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedTieredValidationWorks() + { + LicenseAllocationPrice value = new GroupedTiered() + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredPackageWithMinimumValidationWorks() + { + LicenseAllocationPrice value = new TieredPackageWithMinimum() + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PackageWithAllocationValidationWorks() + { + LicenseAllocationPrice value = new PackageWithAllocation() + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitWithPercentValidationWorks() + { + LicenseAllocationPrice value = new UnitWithPercent() + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithAllocationValidationWorks() + { + LicenseAllocationPrice value = new MatrixWithAllocation() + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void TieredWithProrationValidationWorks() + { + LicenseAllocationPrice value = new TieredWithProration() + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitWithProrationValidationWorks() + { + LicenseAllocationPrice value = new UnitWithProration() + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedAllocationValidationWorks() + { + LicenseAllocationPrice value = new GroupedAllocation() + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithProrationValidationWorks() + { + LicenseAllocationPrice value = new BulkWithProration() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithProratedMinimumValidationWorks() + { + LicenseAllocationPrice value = new GroupedWithProratedMinimum() + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMeteredMinimumValidationWorks() + { + LicenseAllocationPrice value = new GroupedWithMeteredMinimum() + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMinMaxThresholdsValidationWorks() + { + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithDisplayNameValidationWorks() + { + LicenseAllocationPrice value = new MatrixWithDisplayName() + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedTieredPackageValidationWorks() + { + LicenseAllocationPrice value = new GroupedTieredPackage() + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MaxGroupTieredPackageValidationWorks() + { + LicenseAllocationPrice value = new MaxGroupTieredPackage() + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ScalableMatrixWithUnitPricingValidationWorks() + { + LicenseAllocationPrice value = new ScalableMatrixWithUnitPricing() + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void ScalableMatrixWithTieredPricingValidationWorks() + { + LicenseAllocationPrice value = new ScalableMatrixWithTieredPricing() + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedBulkValidationWorks() + { + LicenseAllocationPrice value = new CumulativeGroupedBulk() + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedAllocationValidationWorks() + { + LicenseAllocationPrice value = new CumulativeGroupedAllocation() + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MinimumCompositeValidationWorks() + { + LicenseAllocationPrice value = new MinimumComposite() + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PercentValidationWorks() + { + LicenseAllocationPrice value = new Percent() + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + LicenseAllocationPrice value = new EventOutput() + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new Unit() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new Tiered() + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new Bulk() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithFiltersSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new Package() + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new Matrix() + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ThresholdTotalAmountSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new ThresholdTotalAmount() + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new TieredPackage() + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithMinimumSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new TieredWithMinimum() + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new GroupedTiered() + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageWithMinimumSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new TieredPackageWithMinimum() + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageWithAllocationSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new PackageWithAllocation() + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithPercentSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new UnitWithPercent() + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithAllocationSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new MatrixWithAllocation() + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProrationSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new TieredWithProration() + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithProrationSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new UnitWithProration() + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedAllocationSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new GroupedAllocation() + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithProrationSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new BulkWithProration() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithProratedMinimumSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new GroupedWithProratedMinimum() + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMeteredMinimumSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new GroupedWithMeteredMinimum() + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithDisplayNameSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new MatrixWithDisplayName() + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredPackageSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new GroupedTieredPackage() + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MaxGroupTieredPackageSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new MaxGroupTieredPackage() + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithUnitPricingSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new ScalableMatrixWithUnitPricing() + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithTieredPricingSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new ScalableMatrixWithTieredPricing() + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedBulkSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new CumulativeGroupedBulk() + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new CumulativeGroupedAllocation() + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 MinimumCompositeSerializationRoundtripWorks() + { + LicenseAllocationPrice value = new MinimumComposite() + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + LicenseAllocationPrice value = new Percent() + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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() + { + LicenseAllocationPrice value = new EventOutput() + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = Cadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitConfig, model.UnitConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 = Cadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitConfig, deserialized.UnitConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Unit + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Unit copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CadenceTest : TestBase +{ + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void Validation_Works(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(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void SerializationRoundtrip_Works(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 LicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + LicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ConversionRateConfig 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() + { + ConversionRateConfig 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 TieredTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = TieredCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); + string expectedName = "Annual fee"; + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredConfig, model.TieredConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = TieredCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered"); + string expectedName = "Annual fee"; + Models::TieredConfig expectedTieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredConfig, deserialized.TieredConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tiered + { + Cadence = TieredCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Tiered copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredCadence.Annual)] + [InlineData(TieredCadence.SemiAnnual)] + [InlineData(TieredCadence.Monthly)] + [InlineData(TieredCadence.Quarterly)] + [InlineData(TieredCadence.OneTime)] + [InlineData(TieredCadence.Custom)] + public void Validation_Works(TieredCadence 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(TieredCadence.Annual)] + [InlineData(TieredCadence.SemiAnnual)] + [InlineData(TieredCadence.Monthly)] + [InlineData(TieredCadence.Quarterly)] + [InlineData(TieredCadence.OneTime)] + [InlineData(TieredCadence.Custom)] + public void SerializationRoundtrip_Works(TieredCadence 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 TieredLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredConversionRateConfig 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() + { + TieredConversionRateConfig 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 BulkTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] + ); + ApiEnum expectedCadence = BulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); + 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; + BulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkConfig, model.BulkConfig); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + Models::BulkConfig expectedBulkConfig = new( + [new() { UnitAmount = "unit_amount", MaximumUnits = 0 }] + ); + ApiEnum expectedCadence = BulkCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk"); + 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; + BulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkConfig, deserialized.BulkConfig); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Bulk + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Bulk copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkCadenceTest : TestBase +{ + [Theory] + [InlineData(BulkCadence.Annual)] + [InlineData(BulkCadence.SemiAnnual)] + [InlineData(BulkCadence.Monthly)] + [InlineData(BulkCadence.Quarterly)] + [InlineData(BulkCadence.OneTime)] + [InlineData(BulkCadence.Custom)] + public void Validation_Works(BulkCadence 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(BulkCadence.Annual)] + [InlineData(BulkCadence.SemiAnnual)] + [InlineData(BulkCadence.Monthly)] + [InlineData(BulkCadence.Quarterly)] + [InlineData(BulkCadence.OneTime)] + [InlineData(BulkCadence.Custom)] + public void SerializationRoundtrip_Works(BulkCadence 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 BulkLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + BulkLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + BulkConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkConversionRateConfig 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() + { + BulkConversionRateConfig 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 BulkWithFiltersTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + 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 = BulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + BulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + 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 = BulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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; + BulkWithFiltersConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new 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 = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 SerializationRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new 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 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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 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 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 Filter { PropertyKey = "x", PropertyValue = "x" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + + Filter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new 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); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Tier { 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 Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Tier { UnitAmount = "unit_amount" }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Tier { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new 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 Tier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [InlineData(BulkWithFiltersCadence.Annual)] + [InlineData(BulkWithFiltersCadence.SemiAnnual)] + [InlineData(BulkWithFiltersCadence.Monthly)] + [InlineData(BulkWithFiltersCadence.Quarterly)] + [InlineData(BulkWithFiltersCadence.OneTime)] + [InlineData(BulkWithFiltersCadence.Custom)] + public void Validation_Works(BulkWithFiltersCadence 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(BulkWithFiltersCadence.Annual)] + [InlineData(BulkWithFiltersCadence.SemiAnnual)] + [InlineData(BulkWithFiltersCadence.Monthly)] + [InlineData(BulkWithFiltersCadence.Quarterly)] + [InlineData(BulkWithFiltersCadence.OneTime)] + [InlineData(BulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works(BulkWithFiltersCadence 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 BulkWithFiltersLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + BulkWithFiltersLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithFiltersConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithFiltersConversionRateConfig 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() + { + BulkWithFiltersConversionRateConfig 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 PackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = PackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); + string expectedName = "Annual fee"; + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPackageConfig, model.PackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = PackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("package"); + string expectedName = "Annual fee"; + Models::PackageConfig expectedPackageConfig = new() + { + PackageAmount = "package_amount", + PackageSize = 1, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPackageConfig, deserialized.PackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Package + { + Cadence = PackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Package copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageCadenceTest : TestBase +{ + [Theory] + [InlineData(PackageCadence.Annual)] + [InlineData(PackageCadence.SemiAnnual)] + [InlineData(PackageCadence.Monthly)] + [InlineData(PackageCadence.Quarterly)] + [InlineData(PackageCadence.OneTime)] + [InlineData(PackageCadence.Custom)] + public void Validation_Works(PackageCadence 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(PackageCadence.Annual)] + [InlineData(PackageCadence.SemiAnnual)] + [InlineData(PackageCadence.Monthly)] + [InlineData(PackageCadence.Quarterly)] + [InlineData(PackageCadence.OneTime)] + [InlineData(PackageCadence.Custom)] + public void SerializationRoundtrip_Works(PackageCadence 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 PackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + PackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PackageConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PackageConversionRateConfig 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() + { + PackageConversionRateConfig 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 MatrixTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = MatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); + 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; + MatrixConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, model.MatrixConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = MatrixCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixConfig expectedMatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix"); + 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; + MatrixConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixConfig, deserialized.MatrixConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Matrix + { + Cadence = MatrixCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Matrix copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixCadence.Annual)] + [InlineData(MatrixCadence.SemiAnnual)] + [InlineData(MatrixCadence.Monthly)] + [InlineData(MatrixCadence.Quarterly)] + [InlineData(MatrixCadence.OneTime)] + [InlineData(MatrixCadence.Custom)] + public void Validation_Works(MatrixCadence 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(MatrixCadence.Annual)] + [InlineData(MatrixCadence.SemiAnnual)] + [InlineData(MatrixCadence.Monthly)] + [InlineData(MatrixCadence.Quarterly)] + [InlineData(MatrixCadence.OneTime)] + [InlineData(MatrixCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixCadence 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 MatrixLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MatrixLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixConversionRateConfig 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() + { + MatrixConversionRateConfig 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 ThresholdTotalAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, model.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ThresholdTotalAmountCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + string expectedName = "Annual fee"; + ThresholdTotalAmountConfig expectedThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ThresholdTotalAmountConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedThresholdTotalAmountConfig, deserialized.ThresholdTotalAmountConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmount + { + Cadence = ThresholdTotalAmountCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ThresholdTotalAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdTotalAmountCadenceTest : TestBase +{ + [Theory] + [InlineData(ThresholdTotalAmountCadence.Annual)] + [InlineData(ThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ThresholdTotalAmountCadence.Monthly)] + [InlineData(ThresholdTotalAmountCadence.Quarterly)] + [InlineData(ThresholdTotalAmountCadence.OneTime)] + [InlineData(ThresholdTotalAmountCadence.Custom)] + public void Validation_Works(ThresholdTotalAmountCadence 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(ThresholdTotalAmountCadence.Annual)] + [InlineData(ThresholdTotalAmountCadence.SemiAnnual)] + [InlineData(ThresholdTotalAmountCadence.Monthly)] + [InlineData(ThresholdTotalAmountCadence.Quarterly)] + [InlineData(ThresholdTotalAmountCadence.OneTime)] + [InlineData(ThresholdTotalAmountCadence.Custom)] + public void SerializationRoundtrip_Works(ThresholdTotalAmountCadence 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 ThresholdTotalAmountLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmountLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ThresholdTotalAmountLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdTotalAmountConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; + + Assert.Equal(expectedConsumptionTable.Count, model.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], model.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, model.Prorate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = 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 ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ]; + bool expectedProrate = true; + + Assert.Equal(expectedConsumptionTable.Count, deserialized.ConsumptionTable.Count); + for (int i = 0; i < expectedConsumptionTable.Count; i++) + { + Assert.Equal(expectedConsumptionTable[i], deserialized.ConsumptionTable[i]); + } + Assert.Equal(expectedProrate, deserialized.Prorate); + } + + [Fact] + public void Validation_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + }; + + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + + Prorate = null, + }; + + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + + Prorate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdTotalAmountConfig + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }; + + ThresholdTotalAmountConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ConsumptionTableTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, model.Threshold); + Assert.Equal(expectedTotalAmount, model.TotalAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_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 ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, deserialized.Threshold); + Assert.Equal(expectedTotalAmount, deserialized.TotalAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; + + ConsumptionTable copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdTotalAmountConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ThresholdTotalAmountConversionRateConfig 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() + { + ThresholdTotalAmountConversionRateConfig 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 TieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = TieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + TieredPackageConfig expectedTieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageConfig, model.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = TieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + TieredPackageConfig expectedTieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredPackageConfig, deserialized.TieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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" }, + ], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackage + { + Cadence = TieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredPackageCadence.Annual)] + [InlineData(TieredPackageCadence.SemiAnnual)] + [InlineData(TieredPackageCadence.Monthly)] + [InlineData(TieredPackageCadence.Quarterly)] + [InlineData(TieredPackageCadence.OneTime)] + [InlineData(TieredPackageCadence.Custom)] + public void Validation_Works(TieredPackageCadence 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(TieredPackageCadence.Annual)] + [InlineData(TieredPackageCadence.SemiAnnual)] + [InlineData(TieredPackageCadence.Monthly)] + [InlineData(TieredPackageCadence.Quarterly)] + [InlineData(TieredPackageCadence.OneTime)] + [InlineData(TieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(TieredPackageCadence 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 TieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredPackageLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageConfig + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + TieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + 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 TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredPackageConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredPackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredPackageConversionRateConfig 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() + { + TieredPackageConversionRateConfig 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 TieredWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = TieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + TieredWithMinimumConfig expectedTieredWithMinimumConfig = 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithMinimumConfig, model.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = TieredWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + string expectedName = "Annual fee"; + TieredWithMinimumConfig expectedTieredWithMinimumConfig = 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, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithMinimumConfig, deserialized.TieredWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimum + { + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredWithMinimumCadence.Annual)] + [InlineData(TieredWithMinimumCadence.SemiAnnual)] + [InlineData(TieredWithMinimumCadence.Monthly)] + [InlineData(TieredWithMinimumCadence.Quarterly)] + [InlineData(TieredWithMinimumCadence.OneTime)] + [InlineData(TieredWithMinimumCadence.Custom)] + public void Validation_Works(TieredWithMinimumCadence 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(TieredWithMinimumCadence.Annual)] + [InlineData(TieredWithMinimumCadence.SemiAnnual)] + [InlineData(TieredWithMinimumCadence.Monthly)] + [InlineData(TieredWithMinimumCadence.Quarterly)] + [InlineData(TieredWithMinimumCadence.OneTime)] + [InlineData(TieredWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(TieredWithMinimumCadence 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 TieredWithMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, model.HideZeroAmountTiers); + Assert.Equal(expectedProrate, model.Prorate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + 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 TieredWithMinimumConfig + { + 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, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + bool expectedHideZeroAmountTiers = true; + bool expectedProrate = true; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + Assert.Equal(expectedHideZeroAmountTiers, deserialized.HideZeroAmountTiers); + Assert.Equal(expectedProrate, deserialized.Prorate); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + Assert.Null(model.HideZeroAmountTiers); + Assert.False(model.RawData.ContainsKey("hide_zero_amount_tiers")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithMinimumConfig + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + + // Null should be interpreted as omitted for these properties + HideZeroAmountTiers = null, + Prorate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumConfig + { + 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, + }; + + TieredWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + 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 expectedMinimumAmount = "minimum_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredWithMinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredWithMinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredWithMinimumConversionRateConfig 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() + { + TieredWithMinimumConversionRateConfig 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 GroupedTieredTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = GroupedTieredCadence.Annual; + GroupedTieredConfig expectedGroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + GroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredConfig, model.GroupedTieredConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = GroupedTieredCadence.Annual; + GroupedTieredConfig expectedGroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + 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; + GroupedTieredConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredConfig, deserialized.GroupedTieredConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTiered + { + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedTiered copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedTieredCadence.Annual)] + [InlineData(GroupedTieredCadence.SemiAnnual)] + [InlineData(GroupedTieredCadence.Monthly)] + [InlineData(GroupedTieredCadence.Quarterly)] + [InlineData(GroupedTieredCadence.OneTime)] + [InlineData(GroupedTieredCadence.Custom)] + public void Validation_Works(GroupedTieredCadence 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(GroupedTieredCadence.Annual)] + [InlineData(GroupedTieredCadence.SemiAnnual)] + [InlineData(GroupedTieredCadence.Monthly)] + [InlineData(GroupedTieredCadence.Quarterly)] + [InlineData(GroupedTieredCadence.OneTime)] + [InlineData(GroupedTieredCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedTieredCadence 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 GroupedTieredConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + 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 GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredConfig + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + GroupedTieredConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + 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 GroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + GroupedTieredConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedTieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedTieredLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedTieredConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedTieredConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedTieredConversionRateConfig 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() + { + GroupedTieredConversionRateConfig 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 TieredPackageWithMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + TieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + TieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredPackageWithMinimumConfig, model.TieredPackageWithMinimumConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + TieredPackageWithMinimumCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "tiered_package_with_minimum" + ); + string expectedName = "Annual fee"; + TieredPackageWithMinimumConfig expectedTieredPackageWithMinimumConfig = 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", + }, + ], + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredPackageWithMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedTieredPackageWithMinimumConfig, + deserialized.TieredPackageWithMinimumConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + ], + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimum + { + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredPackageWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredPackageWithMinimumCadence.Annual)] + [InlineData(TieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(TieredPackageWithMinimumCadence.Monthly)] + [InlineData(TieredPackageWithMinimumCadence.Quarterly)] + [InlineData(TieredPackageWithMinimumCadence.OneTime)] + [InlineData(TieredPackageWithMinimumCadence.Custom)] + public void Validation_Works(TieredPackageWithMinimumCadence 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(TieredPackageWithMinimumCadence.Annual)] + [InlineData(TieredPackageWithMinimumCadence.SemiAnnual)] + [InlineData(TieredPackageWithMinimumCadence.Monthly)] + [InlineData(TieredPackageWithMinimumCadence.Quarterly)] + [InlineData(TieredPackageWithMinimumCadence.OneTime)] + [InlineData(TieredPackageWithMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(TieredPackageWithMinimumCadence 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 TieredPackageWithMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredPackageWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedPackageSize = 0; + List expectedTiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ]; + + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumConfig + { + 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", + }, + ], + }; + + TieredPackageWithMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + 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 TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedMinimumAmount = "minimum_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredPackageWithMinimumConfigTier + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + TieredPackageWithMinimumConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredPackageWithMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredPackageWithMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredPackageWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredPackageWithMinimumConversionRateConfig 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() + { + TieredPackageWithMinimumConversionRateConfig 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 PackageWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + PackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + PackageWithAllocationConfig expectedPackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPackageWithAllocationConfig, model.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + PackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "package_with_allocation" + ); + string expectedName = "Annual fee"; + PackageWithAllocationConfig expectedPackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PackageWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPackageWithAllocationConfig, deserialized.PackageWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocation + { + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + PackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(PackageWithAllocationCadence.Annual)] + [InlineData(PackageWithAllocationCadence.SemiAnnual)] + [InlineData(PackageWithAllocationCadence.Monthly)] + [InlineData(PackageWithAllocationCadence.Quarterly)] + [InlineData(PackageWithAllocationCadence.OneTime)] + [InlineData(PackageWithAllocationCadence.Custom)] + public void Validation_Works(PackageWithAllocationCadence 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(PackageWithAllocationCadence.Annual)] + [InlineData(PackageWithAllocationCadence.SemiAnnual)] + [InlineData(PackageWithAllocationCadence.Monthly)] + [InlineData(PackageWithAllocationCadence.Quarterly)] + [InlineData(PackageWithAllocationCadence.OneTime)] + [InlineData(PackageWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(PackageWithAllocationCadence 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 PackageWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + PackageWithAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedPackageAmount, model.PackageAmount); + Assert.Equal(expectedPackageSize, model.PackageSize); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + 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 PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedPackageAmount = "package_amount"; + string expectedPackageSize = "package_size"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedPackageAmount, deserialized.PackageAmount); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + } + + [Fact] + public void Validation_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PackageWithAllocationConfig + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }; + + PackageWithAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PackageWithAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PackageWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PackageWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PackageWithAllocationConversionRateConfig 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() + { + PackageWithAllocationConversionRateConfig 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 UnitWithPercentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = UnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + UnitWithPercentConfig expectedUnitWithPercentConfig = new() + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithPercentConfig, model.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = UnitWithPercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + UnitWithPercentConfig expectedUnitWithPercentConfig = new() + { + Percent = "percent", + UnitAmount = "unit_amount", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithPercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithPercentConfig, deserialized.UnitWithPercentConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercent + { + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + UnitWithPercent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentCadenceTest : TestBase +{ + [Theory] + [InlineData(UnitWithPercentCadence.Annual)] + [InlineData(UnitWithPercentCadence.SemiAnnual)] + [InlineData(UnitWithPercentCadence.Monthly)] + [InlineData(UnitWithPercentCadence.Quarterly)] + [InlineData(UnitWithPercentCadence.OneTime)] + [InlineData(UnitWithPercentCadence.Custom)] + public void Validation_Works(UnitWithPercentCadence 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(UnitWithPercentCadence.Annual)] + [InlineData(UnitWithPercentCadence.SemiAnnual)] + [InlineData(UnitWithPercentCadence.Monthly)] + [InlineData(UnitWithPercentCadence.Quarterly)] + [InlineData(UnitWithPercentCadence.OneTime)] + [InlineData(UnitWithPercentCadence.Custom)] + public void SerializationRoundtrip_Works(UnitWithPercentCadence 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 UnitWithPercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + UnitWithPercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", 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 UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPercent = "percent"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + + UnitWithPercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithPercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + UnitWithPercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + UnitWithPercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + UnitWithPercentConversionRateConfig 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() + { + UnitWithPercentConversionRateConfig 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 MatrixWithAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + MatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, model.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MatrixWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + Models::MatrixWithAllocationConfig expectedMatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + 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; + MatrixWithAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithAllocationConfig, deserialized.MatrixWithAllocationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocation + { + Cadence = MatrixWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MatrixWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithAllocationCadence.Annual)] + [InlineData(MatrixWithAllocationCadence.SemiAnnual)] + [InlineData(MatrixWithAllocationCadence.Monthly)] + [InlineData(MatrixWithAllocationCadence.Quarterly)] + [InlineData(MatrixWithAllocationCadence.OneTime)] + [InlineData(MatrixWithAllocationCadence.Custom)] + public void Validation_Works(MatrixWithAllocationCadence 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(MatrixWithAllocationCadence.Annual)] + [InlineData(MatrixWithAllocationCadence.SemiAnnual)] + [InlineData(MatrixWithAllocationCadence.Monthly)] + [InlineData(MatrixWithAllocationCadence.Quarterly)] + [InlineData(MatrixWithAllocationCadence.OneTime)] + [InlineData(MatrixWithAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithAllocationCadence 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 MatrixWithAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MatrixWithAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithAllocationConversionRateConfig 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() + { + MatrixWithAllocationConversionRateConfig 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 TieredWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + TieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + TieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + string expectedName = "Annual fee"; + TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(TieredWithProrationCadence.Annual)] + [InlineData(TieredWithProrationCadence.SemiAnnual)] + [InlineData(TieredWithProrationCadence.Monthly)] + [InlineData(TieredWithProrationCadence.Quarterly)] + [InlineData(TieredWithProrationCadence.OneTime)] + [InlineData(TieredWithProrationCadence.Custom)] + public void Validation_Works(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>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(TieredWithProrationCadence.Annual)] + [InlineData(TieredWithProrationCadence.SemiAnnual)] + [InlineData(TieredWithProrationCadence.Monthly)] + [InlineData(TieredWithProrationCadence.Quarterly)] + [InlineData(TieredWithProrationCadence.OneTime)] + [InlineData(TieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(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>( + 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 TieredWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + TieredWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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 TieredWithProrationConfig + { + 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 TieredWithProrationConfig + { + 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 TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + 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 TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredWithProrationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + TieredWithProrationConversionRateConfig 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() + { + TieredWithProrationConversionRateConfig 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 UnitWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = UnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + UnitWithProrationConfig expectedUnitWithProrationConfig = new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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 = UnitWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + string expectedName = "Annual fee"; + UnitWithProrationConfig expectedUnitWithProrationConfig = new("unit_amount"); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + UnitWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedUnitWithProrationConfig, deserialized.UnitWithProrationConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProration + { + Cadence = UnitWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + UnitWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(UnitWithProrationCadence.Annual)] + [InlineData(UnitWithProrationCadence.SemiAnnual)] + [InlineData(UnitWithProrationCadence.Monthly)] + [InlineData(UnitWithProrationCadence.Quarterly)] + [InlineData(UnitWithProrationCadence.OneTime)] + [InlineData(UnitWithProrationCadence.Custom)] + public void Validation_Works(UnitWithProrationCadence 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(UnitWithProrationCadence.Annual)] + [InlineData(UnitWithProrationCadence.SemiAnnual)] + [InlineData(UnitWithProrationCadence.Monthly)] + [InlineData(UnitWithProrationCadence.Quarterly)] + [InlineData(UnitWithProrationCadence.OneTime)] + [InlineData(UnitWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(UnitWithProrationCadence 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 UnitWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + UnitWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationConfig { 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 UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationConfig { UnitAmount = "unit_amount" }; + + UnitWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + UnitWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + UnitWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + UnitWithProrationConversionRateConfig 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() + { + UnitWithProrationConversionRateConfig 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 GroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = GroupedAllocationCadence.Annual; + GroupedAllocationConfig expectedGroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + GroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, model.GroupedAllocationConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = GroupedAllocationCadence.Annual; + GroupedAllocationConfig expectedGroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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; + GroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedAllocationConfig, deserialized.GroupedAllocationConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocation + { + Cadence = GroupedAllocationCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedAllocationCadence.Annual)] + [InlineData(GroupedAllocationCadence.SemiAnnual)] + [InlineData(GroupedAllocationCadence.Monthly)] + [InlineData(GroupedAllocationCadence.Quarterly)] + [InlineData(GroupedAllocationCadence.OneTime)] + [InlineData(GroupedAllocationCadence.Custom)] + public void Validation_Works(GroupedAllocationCadence 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(GroupedAllocationCadence.Annual)] + [InlineData(GroupedAllocationCadence.SemiAnnual)] + [InlineData(GroupedAllocationCadence.Monthly)] + [InlineData(GroupedAllocationCadence.Quarterly)] + [InlineData(GroupedAllocationCadence.OneTime)] + [InlineData(GroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedAllocationCadence 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 GroupedAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, model.Allocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedOverageUnitRate, model.OverageUnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_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 GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllocation = "allocation"; + string expectedGroupingKey = "x"; + string expectedOverageUnitRate = "overage_unit_rate"; + + Assert.Equal(expectedAllocation, deserialized.Allocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedOverageUnitRate, deserialized.OverageUnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + GroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedAllocationConversionRateConfig 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() + { + GroupedAllocationConversionRateConfig 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 BulkWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + BulkWithProrationConfig expectedBulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum expectedCadence = BulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + BulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, model.BulkWithProrationConfig); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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); + + BulkWithProrationConfig expectedBulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum expectedCadence = BulkWithProrationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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; + BulkWithProrationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedBulkWithProrationConfig, deserialized.BulkWithProrationConfig); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProration + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + BulkWithProration copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithProrationConfig + { + 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 BulkWithProrationConfig + { + 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 expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "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]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProrationConfigTier + { + 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 BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + BulkWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(BulkWithProrationCadence.Annual)] + [InlineData(BulkWithProrationCadence.SemiAnnual)] + [InlineData(BulkWithProrationCadence.Monthly)] + [InlineData(BulkWithProrationCadence.Quarterly)] + [InlineData(BulkWithProrationCadence.OneTime)] + [InlineData(BulkWithProrationCadence.Custom)] + public void Validation_Works(BulkWithProrationCadence 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(BulkWithProrationCadence.Annual)] + [InlineData(BulkWithProrationCadence.SemiAnnual)] + [InlineData(BulkWithProrationCadence.Monthly)] + [InlineData(BulkWithProrationCadence.Quarterly)] + [InlineData(BulkWithProrationCadence.OneTime)] + [InlineData(BulkWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(BulkWithProrationCadence 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 BulkWithProrationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + BulkWithProrationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BulkWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + BulkWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithProrationConversionRateConfig 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() + { + BulkWithProrationConversionRateConfig 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 GroupedWithProratedMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithProratedMinimumCadence.Annual; + GroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + GroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + model.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithProratedMinimumCadence.Annual; + GroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_prorated_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; + GroupedWithProratedMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithProratedMinimumConfig, + deserialized.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimum + { + Cadence = GroupedWithProratedMinimumCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithProratedMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithProratedMinimumCadence.Annual)] + [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithProratedMinimumCadence.Monthly)] + [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(GroupedWithProratedMinimumCadence.OneTime)] + [InlineData(GroupedWithProratedMinimumCadence.Custom)] + public void Validation_Works(GroupedWithProratedMinimumCadence 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(GroupedWithProratedMinimumCadence.Annual)] + [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithProratedMinimumCadence.Monthly)] + [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(GroupedWithProratedMinimumCadence.OneTime)] + [InlineData(GroupedWithProratedMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithProratedMinimumCadence 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 GroupedWithProratedMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimum, model.Minimum); + Assert.Equal(expectedUnitRate, model.UnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "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 GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimum = "minimum"; + string expectedUnitRate = "unit_rate"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimum, deserialized.Minimum); + Assert.Equal(expectedUnitRate, deserialized.UnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + GroupedWithProratedMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithProratedMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithProratedMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithProratedMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithProratedMinimumConversionRateConfig 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() + { + GroupedWithProratedMinimumConversionRateConfig 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 GroupedWithMeteredMinimumTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithMeteredMinimumCadence.Annual; + GroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + GroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + model.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithMeteredMinimumCadence.Annual; + GroupedWithMeteredMinimumConfig expectedGroupedWithMeteredMinimumConfig = 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" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_metered_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; + GroupedWithMeteredMinimumConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithMeteredMinimumConfig, + deserialized.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimum + { + Cadence = GroupedWithMeteredMinimumCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithMeteredMinimum copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMeteredMinimumCadence.Annual)] + [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(GroupedWithMeteredMinimumCadence.Custom)] + public void Validation_Works(GroupedWithMeteredMinimumCadence 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(GroupedWithMeteredMinimumCadence.Annual)] + [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(GroupedWithMeteredMinimumCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumCadence 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 GroupedWithMeteredMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, model.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, model.PricingKey); + Assert.Equal(expectedScalingFactors.Count, model.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], model.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, model.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + 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 GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMinimumUnitAmount = "minimum_unit_amount"; + string expectedPricingKey = "pricing_key"; + List expectedScalingFactors = + [ + new() { ScalingFactorValue = "scaling_factor", ScalingValue = "scaling_value" }, + ]; + string expectedScalingKey = "scaling_key"; + List expectedUnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMinimumUnitAmount, deserialized.MinimumUnitAmount); + Assert.Equal(expectedPricingKey, deserialized.PricingKey); + Assert.Equal(expectedScalingFactors.Count, deserialized.ScalingFactors.Count); + for (int i = 0; i < expectedScalingFactors.Count; i++) + { + Assert.Equal(expectedScalingFactors[i], deserialized.ScalingFactors[i]); + } + Assert.Equal(expectedScalingKey, deserialized.ScalingKey); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumConfig + { + 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" }, + ], + }; + + GroupedWithMeteredMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string expectedScalingFactorValue = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactorValue, model.ScalingFactorValue); + Assert.Equal(expectedScalingValue, model.ScalingValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + 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 ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedScalingFactorValue = "scaling_factor"; + string expectedScalingValue = "scaling_value"; + + Assert.Equal(expectedScalingFactorValue, deserialized.ScalingFactorValue); + Assert.Equal(expectedScalingValue, deserialized.ScalingValue); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalingFactor + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }; + + ScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmountValue = "unit_amount"; + + Assert.Equal(expectedPricingValue, model.PricingValue); + Assert.Equal(expectedUnitAmountValue, model.UnitAmountValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "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 UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPricingValue = "pricing_value"; + string expectedUnitAmountValue = "unit_amount"; + + Assert.Equal(expectedPricingValue, deserialized.PricingValue); + Assert.Equal(expectedUnitAmountValue, deserialized.UnitAmountValue); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitAmount + { + PricingValue = "pricing_value", + UnitAmountValue = "unit_amount", + }; + + UnitAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithMeteredMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMeteredMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMeteredMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithMeteredMinimumConversionRateConfig 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() + { + GroupedWithMeteredMinimumConversionRateConfig 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 GroupedWithMinMaxThresholdsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedWithMinMaxThresholdsCadence.Annual; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + GroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedWithMinMaxThresholdsCadence.Annual; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + 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; + GroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(GroupedWithMinMaxThresholdsCadence 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(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence 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 GroupedWithMinMaxThresholdsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new 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() + { + var model = new 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 + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new 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 + ); + 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 GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedWithMinMaxThresholdsLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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 MatrixWithDisplayNameTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + MatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, model.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MatrixWithDisplayNameCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + 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; + MatrixWithDisplayNameConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMatrixWithDisplayNameConfig, deserialized.MatrixWithDisplayNameConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayName + { + Cadence = MatrixWithDisplayNameCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MatrixWithDisplayName copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithDisplayNameCadence.Annual)] + [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(MatrixWithDisplayNameCadence.Monthly)] + [InlineData(MatrixWithDisplayNameCadence.Quarterly)] + [InlineData(MatrixWithDisplayNameCadence.OneTime)] + [InlineData(MatrixWithDisplayNameCadence.Custom)] + public void Validation_Works(MatrixWithDisplayNameCadence 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(MatrixWithDisplayNameCadence.Annual)] + [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(MatrixWithDisplayNameCadence.Monthly)] + [InlineData(MatrixWithDisplayNameCadence.Quarterly)] + [InlineData(MatrixWithDisplayNameCadence.OneTime)] + [InlineData(MatrixWithDisplayNameCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithDisplayNameCadence 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 MatrixWithDisplayNameLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MatrixWithDisplayNameLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, model.Dimension); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; + + Assert.Equal(expectedDimension, deserialized.Dimension); + Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) + { + Assert.Equal(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + MatrixWithDisplayNameConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConfigUnitAmountTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, model.DimensionValue); + Assert.Equal(expectedDisplayName, model.DisplayName); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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 MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValue, deserialized.DimensionValue); + Assert.Equal(expectedDisplayName, deserialized.DisplayName); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + MatrixWithDisplayNameConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithDisplayNameConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithDisplayNameConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithDisplayNameConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithDisplayNameConversionRateConfig 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() + { + MatrixWithDisplayNameConversionRateConfig 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 GroupedTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + GroupedTieredPackageCadence.Annual; + GroupedTieredPackageConfig expectedGroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + GroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, model.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + GroupedTieredPackageCadence.Annual; + GroupedTieredPackageConfig expectedGroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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; + GroupedTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedGroupedTieredPackageConfig, deserialized.GroupedTieredPackageConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackage + { + Cadence = GroupedTieredPackageCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedTieredPackageCadence.Annual)] + [InlineData(GroupedTieredPackageCadence.SemiAnnual)] + [InlineData(GroupedTieredPackageCadence.Monthly)] + [InlineData(GroupedTieredPackageCadence.Quarterly)] + [InlineData(GroupedTieredPackageCadence.OneTime)] + [InlineData(GroupedTieredPackageCadence.Custom)] + public void Validation_Works(GroupedTieredPackageCadence 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(GroupedTieredPackageCadence.Annual)] + [InlineData(GroupedTieredPackageCadence.SemiAnnual)] + [InlineData(GroupedTieredPackageCadence.Monthly)] + [InlineData(GroupedTieredPackageCadence.Quarterly)] + [InlineData(GroupedTieredPackageCadence.OneTime)] + [InlineData(GroupedTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedTieredPackageCadence 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 GroupedTieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + GroupedTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + 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 GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + GroupedTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + GroupedTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedTieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedTieredPackageConversionRateConfig 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() + { + GroupedTieredPackageConversionRateConfig 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 MaxGroupTieredPackageTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + MaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, model.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + MaxGroupTieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); + 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; + MaxGroupTieredPackageConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMaxGroupTieredPackageConfig, deserialized.MaxGroupTieredPackageConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackage + { + Cadence = MaxGroupTieredPackageCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MaxGroupTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageCadenceTest : TestBase +{ + [Theory] + [InlineData(MaxGroupTieredPackageCadence.Annual)] + [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(MaxGroupTieredPackageCadence.Monthly)] + [InlineData(MaxGroupTieredPackageCadence.Quarterly)] + [InlineData(MaxGroupTieredPackageCadence.OneTime)] + [InlineData(MaxGroupTieredPackageCadence.Custom)] + public void Validation_Works(MaxGroupTieredPackageCadence 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(MaxGroupTieredPackageCadence.Annual)] + [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(MaxGroupTieredPackageCadence.Monthly)] + [InlineData(MaxGroupTieredPackageCadence.Quarterly)] + [InlineData(MaxGroupTieredPackageCadence.OneTime)] + [InlineData(MaxGroupTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(MaxGroupTieredPackageCadence 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 MaxGroupTieredPackageLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MaxGroupTieredPackageLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPackageSize, model.PackageSize); + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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); + + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPackageSize, deserialized.PackageSize); + 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 MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + MaxGroupTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + 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 MaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + MaxGroupTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MaxGroupTieredPackageConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MaxGroupTieredPackageConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MaxGroupTieredPackageConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MaxGroupTieredPackageConversionRateConfig 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() + { + MaxGroupTieredPackageConversionRateConfig 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 ScalableMatrixWithUnitPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + model.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ScalableMatrixWithUnitPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_unit_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithUnitPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + deserialized.ScalableMatrixWithUnitPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + Cadence = ScalableMatrixWithUnitPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] + public void Validation_Works(ScalableMatrixWithUnitPricingCadence 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(ScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] + public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingCadence 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 ScalableMatrixWithUnitPricingLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ScalableMatrixWithUnitPricingLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedProrate, model.Prorate); + Assert.Equal(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + 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 ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; + bool expectedProrate = true; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); + } + Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedProrate, deserialized.Prorate); + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.False(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.Prorate); + Assert.True(model.RawData.ContainsKey("prorate")); + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + + GroupingKey = null, + Prorate = null, + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + MatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig 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() + { + ScalableMatrixWithUnitPricingConversionRateConfig 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 ScalableMatrixWithTieredPricingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + ScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + model.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + ScalableMatrixWithTieredPricingCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "scalable_matrix_with_tiered_pricing" + ); + string expectedName = "Annual fee"; + ScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = 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", + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ScalableMatrixWithTieredPricingConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal( + expectedScalableMatrixWithTieredPricingConfig, + deserialized.ScalableMatrixWithTieredPricingConfig + ); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + Cadence = ScalableMatrixWithTieredPricingCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingCadenceTest : TestBase +{ + [Theory] + [InlineData(ScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] + public void Validation_Works(ScalableMatrixWithTieredPricingCadence 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(ScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] + public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingCadence 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 ScalableMatrixWithTieredPricingLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ScalableMatrixWithTieredPricingLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, model.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[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(expectedSecondDimension, model.SecondDimension); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + 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 ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimension = "first_dimension"; + List expectedMatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ]; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + string expectedSecondDimension = "second_dimension"; + + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixScalingFactors.Count, deserialized.MatrixScalingFactors.Count); + for (int i = 0; i < expectedMatrixScalingFactors.Count; i++) + { + Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[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(expectedSecondDimension, deserialized.SecondDimension); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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 = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfig + { + 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", + }; + + ScalableMatrixWithTieredPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + 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 ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ScalableMatrixWithTieredPricingConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ScalableMatrixWithTieredPricingConversionRateConfig 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() + { + ScalableMatrixWithTieredPricingConversionRateConfig 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 CumulativeGroupedBulkTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + CumulativeGroupedBulkCadence.Annual; + CumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + CumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, model.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + CumulativeGroupedBulkCadence.Annual; + CumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_bulk" + ); + 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; + CumulativeGroupedBulkConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedCumulativeGroupedBulkConfig, deserialized.CumulativeGroupedBulkConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulk + { + Cadence = CumulativeGroupedBulkCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + CumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkCadenceTest : TestBase +{ + [Theory] + [InlineData(CumulativeGroupedBulkCadence.Annual)] + [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(CumulativeGroupedBulkCadence.Monthly)] + [InlineData(CumulativeGroupedBulkCadence.Quarterly)] + [InlineData(CumulativeGroupedBulkCadence.OneTime)] + [InlineData(CumulativeGroupedBulkCadence.Custom)] + public void Validation_Works(CumulativeGroupedBulkCadence 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(CumulativeGroupedBulkCadence.Annual)] + [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(CumulativeGroupedBulkCadence.Monthly)] + [InlineData(CumulativeGroupedBulkCadence.Quarterly)] + [InlineData(CumulativeGroupedBulkCadence.OneTime)] + [InlineData(CumulativeGroupedBulkCadence.Custom)] + public void SerializationRoundtrip_Works(CumulativeGroupedBulkCadence 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 CumulativeGroupedBulkConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } + Assert.Equal(expectedGroup, model.Group); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + 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 CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedDimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ]; + string expectedGroup = "group"; + + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } + Assert.Equal(expectedGroup, deserialized.Group); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + CumulativeGroupedBulkConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DimensionValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + 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 DimensionValue + { + GroupingKey = "x", + 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 expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + DimensionValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + CumulativeGroupedBulkLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + CumulativeGroupedBulkConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + CumulativeGroupedBulkConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + CumulativeGroupedBulkConversionRateConfig 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() + { + CumulativeGroupedBulkConversionRateConfig 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 CumulativeGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + CumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + 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; + CumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationCadenceTest : TestBase +{ + [Theory] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [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.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + CumulativeGroupedAllocationLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + CumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + CumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + CumulativeGroupedAllocationConversionRateConfig 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() + { + CumulativeGroupedAllocationConversionRateConfig 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 MinimumCompositeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = MinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MinimumCompositeConfig expectedMinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + MinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, model.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + 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 = MinimumCompositeCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + MinimumCompositeConfig expectedMinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); + 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; + MinimumCompositeConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(expectedMinimumCompositeConfig, deserialized.MinimumCompositeConfig); + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumComposite + { + Cadence = MinimumCompositeCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MinimumComposite copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeCadenceTest : TestBase +{ + [Theory] + [InlineData(MinimumCompositeCadence.Annual)] + [InlineData(MinimumCompositeCadence.SemiAnnual)] + [InlineData(MinimumCompositeCadence.Monthly)] + [InlineData(MinimumCompositeCadence.Quarterly)] + [InlineData(MinimumCompositeCadence.OneTime)] + [InlineData(MinimumCompositeCadence.Custom)] + public void Validation_Works(MinimumCompositeCadence 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(MinimumCompositeCadence.Annual)] + [InlineData(MinimumCompositeCadence.SemiAnnual)] + [InlineData(MinimumCompositeCadence.Monthly)] + [InlineData(MinimumCompositeCadence.Quarterly)] + [InlineData(MinimumCompositeCadence.OneTime)] + [InlineData(MinimumCompositeCadence.Custom)] + public void SerializationRoundtrip_Works(MinimumCompositeCadence 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 MinimumCompositeLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + MinimumCompositeLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MinimumCompositeConfig { MinimumAmount = "minimum_amount" }; + + Assert.Null(model.Prorated); + Assert.False(model.RawData.ContainsKey("prorated")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new MinimumCompositeConfig { MinimumAmount = "minimum_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new MinimumCompositeConfig + { + 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 MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + + // Null should be interpreted as omitted for these properties + Prorated = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MinimumCompositeConfig + { + MinimumAmount = "minimum_amount", + Prorated = true, + }; + + MinimumCompositeConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MinimumCompositeConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MinimumCompositeConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MinimumCompositeConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MinimumCompositeConversionRateConfig 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() + { + MinimumCompositeConversionRateConfig 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] + public void FieldRoundtrip_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = PercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + 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 = PercentCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PercentConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PercentConfig = new(0), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentCadenceTest : 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) + { + // 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(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; + + 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 PercentLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PercentLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PercentLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + PercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PercentConfig { Percent = 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 PercentConfig { Percent = 0 }; + + 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 Validation_Works() + { + var model = new PercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PercentConversionRateConfig 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() + { + PercentConversionRateConfig 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 EventOutputTest : 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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + 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 = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + 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, + }; + string expectedLicenseTypeID = "license_type_id"; + 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.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + 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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } +} + +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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new EventOutputConfig + { + 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 EventOutputConfig + { + 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 EventOutputConfig + { + 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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EventOutputLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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 EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new EventOutputLicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new EventOutputLicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() { - var model = new Price { }; + var model = new EventOutputLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.PriceValue); - Assert.False(model.RawData.ContainsKey("price")); + EventOutputLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); } +} +public class EventOutputConversionRateConfigTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void UnitValidationWorks() { - var model = new Price { }; - - model.Validate(); + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void TieredValidationWorks() { - var model = new Price + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - AllocationPrice = null, - PlanPhaseOrder = null, - PriceValue = null, + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; - - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.PriceValue); - Assert.True(model.RawData.ContainsKey("price")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void UnitSerializationRoundtripWorks() { - var model = new Price + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - AllocationPrice = null, - PlanPhaseOrder = null, - PriceValue = null, + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void CopyConstructor_Works() + public void TieredSerializationRoundtripWorks() { - var model = new Price + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, - ], - ItemID = "item_id", - LicenseTypeID = "license_type_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, - }, - LicenseTypeID = "license_type_id", - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, + ] + ), }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Price copied = new(model); - - Assert.Equal(model, copied); + Assert.Equal(value, deserialized); } } @@ -1673,7 +42446,7 @@ public void NewPlanBulkValidationWorks() [Fact] public void BulkWithFiltersValidationWorks() { - PricePrice value = new BulkWithFilters() + PricePrice value = new PricePriceBulkWithFilters() { BulkWithFiltersConfig = new() { @@ -1684,7 +42457,7 @@ public void BulkWithFiltersValidationWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -2253,9 +43026,9 @@ public void NewPlanMatrixWithAllocationValidationWorks() [Fact] public void TieredWithProrationValidationWorks() { - PricePrice value = new TieredWithProration() + PricePrice value = new PricePriceTieredWithProration() { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -2555,9 +43328,9 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() [Fact] public void GroupedWithMinMaxThresholdsValidationWorks() { - PricePrice value = new GroupedWithMinMaxThresholds() + PricePrice value = new PricePriceGroupedWithMinMaxThresholds() { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -2953,9 +43726,9 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() [Fact] public void CumulativeGroupedAllocationValidationWorks() { - PricePrice value = new CumulativeGroupedAllocation() + PricePrice value = new PricePriceCumulativeGroupedAllocation() { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -3048,9 +43821,9 @@ public void NewPlanMinimumCompositeValidationWorks() [Fact] public void PercentValidationWorks() { - PricePrice value = new Percent() + PricePrice value = new PricePricePercent() { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -3092,9 +43865,9 @@ public void PercentValidationWorks() [Fact] public void EventOutputValidationWorks() { - PricePrice value = new EventOutput() + PricePrice value = new PricePriceEventOutput() { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -3306,7 +44079,7 @@ public void NewPlanBulkSerializationRoundtripWorks() [Fact] public void BulkWithFiltersSerializationRoundtripWorks() { - PricePrice value = new BulkWithFilters() + PricePrice value = new PricePriceBulkWithFilters() { BulkWithFiltersConfig = new() { @@ -3317,7 +44090,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -3952,9 +44725,9 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() [Fact] public void TieredWithProrationSerializationRoundtripWorks() { - PricePrice value = new TieredWithProration() + PricePrice value = new PricePriceTieredWithProration() { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -4290,9 +45063,9 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() [Fact] public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - PricePrice value = new GroupedWithMinMaxThresholds() + PricePrice value = new PricePriceGroupedWithMinMaxThresholds() { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -4730,9 +45503,9 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() [Fact] public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - PricePrice value = new CumulativeGroupedAllocation() + PricePrice value = new PricePriceCumulativeGroupedAllocation() { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -4837,9 +45610,9 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() [Fact] public void PercentSerializationRoundtripWorks() { - PricePrice value = new Percent() + PricePrice value = new PricePricePercent() { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -4887,9 +45660,9 @@ public void PercentSerializationRoundtripWorks() [Fact] public void EventOutputSerializationRoundtripWorks() { - PricePrice value = new EventOutput() + PricePrice value = new PricePriceEventOutput() { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -4940,12 +45713,12 @@ public void EventOutputSerializationRoundtripWorks() } } -public class BulkWithFiltersTest : TestBase +public class PricePriceBulkWithFiltersTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -4956,7 +45729,7 @@ public void FieldRoundtrip_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -4992,7 +45765,7 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + PricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() { Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = @@ -5001,7 +45774,8 @@ public void FieldRoundtrip_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }; - ApiEnum expectedCadence = Cadence.Annual; + ApiEnum expectedCadence = + PricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; @@ -5013,7 +45787,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + PricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5069,7 +45843,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5080,7 +45854,7 @@ public void SerializationRoundtrip_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5117,7 +45891,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -5128,7 +45902,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5139,7 +45913,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5176,13 +45950,13 @@ 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); - BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + PricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() { Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = @@ -5191,7 +45965,8 @@ public void FieldRoundtripThroughSerialization_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }; - ApiEnum expectedCadence = Cadence.Annual; + ApiEnum expectedCadence = + PricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; @@ -5203,7 +45978,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + PricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5262,7 +46037,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5273,7 +46048,7 @@ public void Validation_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5315,7 +46090,7 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5326,7 +46101,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -5364,7 +46139,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5375,7 +46150,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -5386,7 +46161,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5397,7 +46172,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -5450,7 +46225,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5461,7 +46236,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -5487,7 +46262,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new BulkWithFilters + var model = new PricePriceBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5498,7 +46273,7 @@ public void CopyConstructor_Works() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = PricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5534,18 +46309,18 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - BulkWithFilters copied = new(model); + PricePriceBulkWithFilters copied = new(model); Assert.Equal(model, copied); } } -public class BulkWithFiltersConfigTest : TestBase +public class PricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFiltersConfig + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfig { Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = @@ -5555,8 +46330,11 @@ public void FieldRoundtrip_Works() ], }; - List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; - List expectedTiers = + 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" }, @@ -5577,7 +46355,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFiltersConfig + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfig { Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = @@ -5588,10 +46366,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); } @@ -5599,7 +46378,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFiltersConfig + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfig { Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = @@ -5610,14 +46389,18 @@ 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); - List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; - List expectedTiers = + 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" }, @@ -5638,7 +46421,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFiltersConfig + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfig { Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = @@ -5654,7 +46437,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new BulkWithFiltersConfig + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfig { Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = @@ -5664,18 +46447,22 @@ public void CopyConstructor_Works() ], }; - BulkWithFiltersConfig copied = new(model); + PricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); Assert.Equal(model, copied); } } -public class FilterTest : TestBase +public class PricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; string expectedPropertyKey = "x"; string expectedPropertyValue = "x"; @@ -5687,10 +46474,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; 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); } @@ -5698,10 +46493,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; 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 expectedPropertyKey = "x"; @@ -5714,7 +46517,11 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; model.Validate(); } @@ -5722,20 +46529,28 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - Filter copied = new(model); + PricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); Assert.Equal(model, copied); } } -public class TierTest : TestBase +public class PricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; string expectedUnitAmount = "unit_amount"; string expectedTierLowerBound = "tier_lower_bound"; @@ -5747,10 +46562,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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); } @@ -5758,10 +46581,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 expectedUnitAmount = "unit_amount"; @@ -5774,7 +46605,11 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; model.Validate(); } @@ -5782,7 +46617,10 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Tier { UnitAmount = "unit_amount" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; Assert.Null(model.TierLowerBound); Assert.False(model.RawData.ContainsKey("tier_lower_bound")); @@ -5791,7 +46629,10 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Tier { UnitAmount = "unit_amount" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; model.Validate(); } @@ -5799,7 +46640,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Tier + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier { UnitAmount = "unit_amount", @@ -5813,7 +46654,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Tier + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier { UnitAmount = "unit_amount", @@ -5826,34 +46667,38 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; - Tier copied = new(model); + PricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); Assert.Equal(model, copied); } } -public class CadenceTest : TestBase +public class PricePriceBulkWithFiltersCadenceTest : TestBase { [Theory] - [InlineData(Cadence.Annual)] - [InlineData(Cadence.SemiAnnual)] - [InlineData(Cadence.Monthly)] - [InlineData(Cadence.Quarterly)] - [InlineData(Cadence.OneTime)] - [InlineData(Cadence.Custom)] - public void Validation_Works(Cadence rawValue) + [InlineData(PricePriceBulkWithFiltersCadence.Annual)] + [InlineData(PricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(PricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(PricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(PricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(PricePriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(PricePriceBulkWithFiltersCadence 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 ); @@ -5863,22 +46708,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Cadence.Annual)] - [InlineData(Cadence.SemiAnnual)] - [InlineData(Cadence.Monthly)] - [InlineData(Cadence.Quarterly)] - [InlineData(Cadence.OneTime)] - [InlineData(Cadence.Custom)] - public void SerializationRoundtrip_Works(Cadence rawValue) + [InlineData(PricePriceBulkWithFiltersCadence.Annual)] + [InlineData(PricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(PricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(PricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(PricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(PricePriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works(PricePriceBulkWithFiltersCadence 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); } @@ -5886,66 +46730,69 @@ public void SerializationRoundtrip_Works(Cadence 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 ConversionRateConfigTest : TestBase +public class PricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + PricePriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + PricePriceBulkWithFiltersConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + PricePriceBulkWithFiltersConversionRateConfig 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); } @@ -5953,38 +46800,40 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + PricePriceBulkWithFiltersConversionRateConfig 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 - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class TieredWithProrationTest : TestBase +public class PricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6023,14 +46872,13 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = + PricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; - TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); + PricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6039,7 +46887,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + PricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6095,9 +46943,9 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6137,7 +46985,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6148,9 +46996,9 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6190,20 +47038,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 = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = + PricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; - TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); + PricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6212,7 +47059,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + PricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6271,9 +47118,9 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6318,9 +47165,9 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6361,9 +47208,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6377,9 +47224,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6435,9 +47282,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6466,9 +47313,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new TieredWithProration + var model = new PricePriceTieredWithProration { - Cadence = TieredWithProrationCadence.Annual, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", TieredWithProrationConfig = new( @@ -6507,57 +47354,55 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - TieredWithProration copied = new(model); + PricePriceTieredWithProration copied = new(model); Assert.Equal(model, copied); } } -public class TieredWithProrationCadenceTest : TestBase +public class PricePriceTieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Custom)] - public void Validation_Works(TieredWithProrationCadence rawValue) + [InlineData(PricePriceTieredWithProrationCadence.Annual)] + [InlineData(PricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(PricePriceTieredWithProrationCadence.Monthly)] + [InlineData(PricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(PricePriceTieredWithProrationCadence.OneTime)] + [InlineData(PricePriceTieredWithProrationCadence.Custom)] + public void Validation_Works(PricePriceTieredWithProrationCadence 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(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) + [InlineData(PricePriceTieredWithProrationCadence.Annual)] + [InlineData(PricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(PricePriceTieredWithProrationCadence.Monthly)] + [InlineData(PricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(PricePriceTieredWithProrationCadence.OneTime)] + [InlineData(PricePriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(PricePriceTieredWithProrationCadence 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); } @@ -6565,31 +47410,29 @@ public void SerializationRoundtrip_Works(TieredWithProrationCadence 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 TieredWithProrationConfigTest : TestBase +public class PricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig { Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - List expectedTiers = + List expectedTiers = [ new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ]; @@ -6604,16 +47447,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig { Tiers = [new() { TierLowerBound = "tier_lower_bound", 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); } @@ -6621,19 +47465,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig { Tiers = [new() { TierLowerBound = "tier_lower_bound", 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); - List expectedTiers = + List expectedTiers = [ new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ]; @@ -6648,7 +47493,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig { Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; @@ -6659,23 +47504,23 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new TieredWithProrationConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig { Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - TieredWithProrationConfig copied = new(model); + PricePriceTieredWithProrationTieredWithProrationConfig copied = new(model); Assert.Equal(model, copied); } } -public class TieredWithProrationConfigTierTest : TestBase +public class PricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfigTier + var model = new PricePriceTieredWithProrationTieredWithProrationConfigTier { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", @@ -6691,17 +47536,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfigTier + var model = new PricePriceTieredWithProrationTieredWithProrationConfigTier { TierLowerBound = "tier_lower_bound", 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); } @@ -6709,17 +47555,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfigTier + var model = new PricePriceTieredWithProrationTieredWithProrationConfigTier { TierLowerBound = "tier_lower_bound", 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 expectedTierLowerBound = "tier_lower_bound"; @@ -6732,7 +47579,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfigTier + var model = new PricePriceTieredWithProrationTieredWithProrationConfigTier { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", @@ -6744,35 +47591,36 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new TieredWithProrationConfigTier + var model = new PricePriceTieredWithProrationTieredWithProrationConfigTier { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; - TieredWithProrationConfigTier copied = new(model); + PricePriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); Assert.Equal(model, copied); } } -public class TieredWithProrationConversionRateConfigTest : TestBase +public class PricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + PricePriceTieredWithProrationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - TieredWithProrationConversionRateConfig value = + PricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6793,16 +47641,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + PricePriceTieredWithProrationConversionRateConfig 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); } @@ -6810,7 +47660,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = + PricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6826,23 +47676,24 @@ 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); } } -public class GroupedWithMinMaxThresholdsTest : TestBase +public class PricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -6885,15 +47736,16 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - GroupedWithMinMaxThresholdsCadence.Annual; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + PricePriceGroupedWithMinMaxThresholdsCadence.Annual; + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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" @@ -6907,7 +47759,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6966,9 +47818,9 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -7012,7 +47864,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7023,9 +47875,9 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -7069,21 +47921,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 = - GroupedWithMinMaxThresholdsCadence.Annual; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + PricePriceGroupedWithMinMaxThresholdsCadence.Annual; + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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" @@ -7097,7 +47950,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7159,9 +48012,9 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -7210,9 +48063,9 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -7257,9 +48110,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -7277,9 +48130,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -7339,9 +48192,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -7374,9 +48227,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", @@ -7419,55 +48272,54 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - GroupedWithMinMaxThresholds copied = new(model); + PricePriceGroupedWithMinMaxThresholds copied = new(model); Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class PricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(GroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(PricePriceGroupedWithMinMaxThresholdsCadence 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(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(PricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works(PricePriceGroupedWithMinMaxThresholdsCadence 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); @@ -7476,25 +48328,24 @@ public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence rawV [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 GroupedWithMinMaxThresholdsConfigTest : TestBase +public class PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { GroupingKey = "x", MaximumCharge = "maximum_charge", @@ -7516,7 +48367,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { GroupingKey = "x", MaximumCharge = "maximum_charge", @@ -7525,10 +48376,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); } @@ -7536,7 +48388,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { GroupingKey = "x", MaximumCharge = "maximum_charge", @@ -7545,10 +48397,11 @@ 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); string expectedGroupingKey = "x"; @@ -7565,7 +48418,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { GroupingKey = "x", MaximumCharge = "maximum_charge", @@ -7579,7 +48432,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { GroupingKey = "x", MaximumCharge = "maximum_charge", @@ -7587,18 +48440,18 @@ public void CopyConstructor_Works() PerUnitRate = "per_unit_rate", }; - GroupedWithMinMaxThresholdsConfig copied = new(model); + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new(model); Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class PricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7610,7 +48463,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7631,7 +48484,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7639,7 +48492,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7650,7 +48503,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7667,7 +48520,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7676,14 +48529,14 @@ public void TieredSerializationRoundtripWorks() } } -public class CumulativeGroupedAllocationTest : TestBase +public class PricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -7726,15 +48579,16 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + ApiEnum expectedCadence = + PricePriceCumulativeGroupedAllocationCadence.Annual; + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( "cumulative_grouped_allocation" @@ -7748,7 +48602,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7807,9 +48661,9 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -7853,7 +48707,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7864,9 +48718,9 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -7910,21 +48764,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 = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + ApiEnum expectedCadence = + PricePriceCumulativeGroupedAllocationCadence.Annual; + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( "cumulative_grouped_allocation" @@ -7938,7 +48793,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8000,9 +48855,9 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -8051,9 +48906,9 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -8098,9 +48953,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -8118,9 +48973,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -8180,9 +49035,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -8215,9 +49070,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = CumulativeGroupedAllocationCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() { CumulativeAllocation = "cumulative_allocation", @@ -8260,55 +49115,54 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - CumulativeGroupedAllocation copied = new(model); + PricePriceCumulativeGroupedAllocation copied = new(model); Assert.Equal(model, copied); } } -public class CumulativeGroupedAllocationCadenceTest : TestBase +public class PricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(PricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(PricePriceCumulativeGroupedAllocationCadence 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(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) + [Theory] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(PricePriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(PricePriceCumulativeGroupedAllocationCadence 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); @@ -8317,25 +49171,24 @@ public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawV [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 CumulativeGroupedAllocationConfigTest : TestBase +public class PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { CumulativeAllocation = "cumulative_allocation", GroupAllocation = "group_allocation", @@ -8357,7 +49210,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { CumulativeAllocation = "cumulative_allocation", GroupAllocation = "group_allocation", @@ -8366,10 +49219,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); } @@ -8377,7 +49231,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { CumulativeAllocation = "cumulative_allocation", GroupAllocation = "group_allocation", @@ -8386,10 +49240,11 @@ 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); string expectedCumulativeAllocation = "cumulative_allocation"; @@ -8406,7 +49261,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { CumulativeAllocation = "cumulative_allocation", GroupAllocation = "group_allocation", @@ -8420,7 +49275,7 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { CumulativeAllocation = "cumulative_allocation", GroupAllocation = "group_allocation", @@ -8428,18 +49283,18 @@ public void CopyConstructor_Works() UnitAmount = "unit_amount", }; - CumulativeGroupedAllocationConfig copied = new(model); + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new(model); Assert.Equal(model, copied); } } -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class PricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + PricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8451,7 +49306,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + PricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -8472,7 +49327,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + PricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8480,7 +49335,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8491,7 +49346,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + PricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -8508,7 +49363,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8517,14 +49372,14 @@ public void TieredSerializationRoundtripWorks() } } -public class PercentTest : TestBase +public class PricePricePercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -8561,11 +49416,11 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = PercentCadence.Annual; + ApiEnum expectedCadence = PricePricePercentCadence.Annual; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); + PricePricePercentPercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8574,7 +49429,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + PricePricePercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8630,9 +49485,9 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -8670,7 +49525,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); } @@ -8678,9 +49536,9 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -8718,17 +49576,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 = PercentCadence.Annual; + ApiEnum expectedCadence = PricePricePercentCadence.Annual; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); + PricePricePercentPercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8737,7 +49595,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + PricePricePercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8796,9 +49654,9 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -8841,9 +49699,9 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -8882,9 +49740,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -8896,9 +49754,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -8952,9 +49810,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -8981,9 +49839,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new Percent + var model = new PricePricePercent { - Cadence = PercentCadence.Annual, + Cadence = PricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", PercentConfig = new(0), @@ -9020,32 +49878,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - Percent copied = new(model); + PricePricePercent copied = new(model); Assert.Equal(model, copied); } } -public class PercentCadenceTest : TestBase +public class PricePricePercentCadenceTest : 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(PricePricePercentCadence.Annual)] + [InlineData(PricePricePercentCadence.SemiAnnual)] + [InlineData(PricePricePercentCadence.Monthly)] + [InlineData(PricePricePercentCadence.Quarterly)] + [InlineData(PricePricePercentCadence.OneTime)] + [InlineData(PricePricePercentCadence.Custom)] + public void Validation_Works(PricePricePercentCadence 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 ); @@ -9055,19 +49913,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(PricePricePercentCadence.Annual)] + [InlineData(PricePricePercentCadence.SemiAnnual)] + [InlineData(PricePricePercentCadence.Monthly)] + [InlineData(PricePricePercentCadence.Quarterly)] + [InlineData(PricePricePercentCadence.OneTime)] + [InlineData(PricePricePercentCadence.Custom)] + public void SerializationRoundtrip_Works(PricePricePercentCadence 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 ); @@ -9078,12 +49936,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 ); @@ -9092,12 +49950,12 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PercentConfigTest : TestBase +public class PricePricePercentPercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PricePricePercentPercentConfig { Percent = 0 }; double expectedPercent = 0; @@ -9107,10 +49965,10 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PricePricePercentPercentConfig { Percent = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9121,10 +49979,10 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PricePricePercentPercentConfig { Percent = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9138,7 +49996,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PricePricePercentPercentConfig { Percent = 0 }; model.Validate(); } @@ -9146,20 +50004,20 @@ public void Validation_Works() [Fact] public void CopyConstructor_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PricePricePercentPercentConfig { Percent = 0 }; - PercentConfig copied = new(model); + PricePricePercentPercentConfig copied = new(model); Assert.Equal(model, copied); } } -public class PercentConversionRateConfigTest : TestBase +public class PricePricePercentConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PricePricePercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -9170,7 +50028,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PricePricePercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9190,13 +50048,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PricePricePercentConversionRateConfig 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 ); @@ -9207,7 +50065,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PricePricePercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9222,7 +50080,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9231,14 +50089,14 @@ public void TieredSerializationRoundtripWorks() } } -public class EventOutputTest : TestBase +public class PricePriceEventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9280,8 +50138,9 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = + PricePriceEventOutputCadence.Annual; + PricePriceEventOutputEventOutputConfig expectedEventOutputConfig = new() { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", @@ -9298,7 +50157,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + PricePriceEventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9354,9 +50213,9 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9399,7 +50258,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9410,9 +50269,9 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9455,14 +50314,15 @@ 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 = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = + PricePriceEventOutputCadence.Annual; + PricePriceEventOutputEventOutputConfig expectedEventOutputConfig = new() { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", @@ -9479,7 +50339,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + PricePriceEventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9538,9 +50398,9 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9588,9 +50448,9 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9634,9 +50494,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9653,9 +50513,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9714,9 +50574,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9748,9 +50608,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new EventOutput + var model = new PricePriceEventOutput { - Cadence = EventOutputCadence.Annual, + Cadence = PricePriceEventOutputCadence.Annual, EventOutputConfig = new() { UnitRatingKey = "x", @@ -9792,32 +50652,32 @@ public void CopyConstructor_Works() ReferenceID = "reference_id", }; - EventOutput copied = new(model); + PricePriceEventOutput copied = new(model); Assert.Equal(model, copied); } } -public class EventOutputCadenceTest : TestBase +public class PricePriceEventOutputCadenceTest : 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) + [InlineData(PricePriceEventOutputCadence.Annual)] + [InlineData(PricePriceEventOutputCadence.SemiAnnual)] + [InlineData(PricePriceEventOutputCadence.Monthly)] + [InlineData(PricePriceEventOutputCadence.Quarterly)] + [InlineData(PricePriceEventOutputCadence.OneTime)] + [InlineData(PricePriceEventOutputCadence.Custom)] + public void Validation_Works(PricePriceEventOutputCadence 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 ); @@ -9827,22 +50687,21 @@ public void InvalidEnumValidationThrows_Works() } [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) + [InlineData(PricePriceEventOutputCadence.Annual)] + [InlineData(PricePriceEventOutputCadence.SemiAnnual)] + [InlineData(PricePriceEventOutputCadence.Monthly)] + [InlineData(PricePriceEventOutputCadence.Quarterly)] + [InlineData(PricePriceEventOutputCadence.OneTime)] + [InlineData(PricePriceEventOutputCadence.Custom)] + public void SerializationRoundtrip_Works(PricePriceEventOutputCadence 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); } @@ -9850,26 +50709,25 @@ public void SerializationRoundtrip_Works(EventOutputCadence 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 EventOutputConfigTest : TestBase +public class PricePriceEventOutputEventOutputConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", @@ -9888,7 +50746,7 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", @@ -9896,7 +50754,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9907,7 +50765,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", @@ -9915,7 +50773,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9933,7 +50791,7 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", @@ -9946,7 +50804,7 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x" }; Assert.Null(model.DefaultUnitRate); Assert.False(model.RawData.ContainsKey("default_unit_rate")); @@ -9957,7 +50815,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x" }; model.Validate(); } @@ -9965,7 +50823,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", @@ -9982,7 +50840,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", @@ -9996,62 +50854,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() [Fact] public void CopyConstructor_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", GroupingKey = "grouping_key", }; - EventOutputConfig copied = new(model); + PricePriceEventOutputEventOutputConfig copied = new(model); Assert.Equal(model, copied); } } -public class EventOutputConversionRateConfigTest : TestBase +public class PricePriceEventOutputConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + PricePriceEventOutputConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + PricePriceEventOutputConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + PricePriceEventOutputConversionRateConfig 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 ); @@ -10062,22 +50923,23 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + PricePriceEventOutputConversionRateConfig 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Orb.Tests/Services/PlanServiceTest.cs b/src/Orb.Tests/Services/PlanServiceTest.cs index 6277e0030..918b1e39e 100644 --- a/src/Orb.Tests/Services/PlanServiceTest.cs +++ b/src/Orb.Tests/Services/PlanServiceTest.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Orb.Models; +using Plans = Orb.Models.Plans; namespace Orb.Tests.Services; @@ -42,6 +43,55 @@ public async Task Create_Works() LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new Plans::Unit() + { + Cadence = Plans::Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, PlanPhaseOrder = 0, PriceValue = new NewPlanUnitPrice() { diff --git a/src/Orb/Core/ModelBase.cs b/src/Orb/Core/ModelBase.cs index 2ebc67343..01d4c5d82 100644 --- a/src/Orb/Core/ModelBase.cs +++ b/src/Orb/Core/ModelBase.cs @@ -428,11 +428,148 @@ 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(), + 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(), + 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(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence + >(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceTieredPackageCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceGroupedTieredCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPricePackageWithAllocationCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceUnitWithPercentCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceTieredWithProrationCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceUnitWithProrationCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceGroupedAllocationCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceBulkWithProrationCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + >(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceMinimumCompositeCadence + >(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + Beta::ReplacePriceLicenseAllocationPriceEventOutputCadence + >(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter< @@ -446,11 +583,166 @@ 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(), + 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(), + 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(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceUnitCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceTieredCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceBulkCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPricePackageCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceMatrixCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceTieredPackageCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceGroupedTieredCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPricePackageWithAllocationCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceUnitWithPercentCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceTieredWithProrationCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceUnitWithProrationCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceGroupedAllocationCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceBulkWithProrationCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceMinimumCompositeCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPricePercentCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceEventOutputCadence + >(), new ApiEnumConverter(), new ApiEnumConverter< string, @@ -601,11 +893,42 @@ 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(), + 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(), + 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(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), diff --git a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs index e3ea1b734..af25f908b 100644 --- a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs @@ -882,6 +882,21 @@ public NewAllocationPrice? AllocationPrice init { this._rawData.Set("allocation_price", value); } } + /// + /// The license allocation price to add to the plan. + /// + public LicenseAllocationPrice? LicenseAllocationPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_allocation_price" + ); + } + init { this._rawData.Set("license_allocation_price", value); } + } + /// /// The phase to add this price to. /// @@ -912,6 +927,7 @@ public Price? Price public override void Validate() { this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); _ = this.PlanPhaseOrder; this.Price?.Validate(); } @@ -952,10 +968,10 @@ public AddPrice FromRawUnchecked(IReadOnlyDictionary rawDat } /// -/// New plan price request body params. +/// The license allocation price to add to the plan. /// -[JsonConverter(typeof(PriceConverter))] -public record class Price : ModelBase +[JsonConverter(typeof(LicenseAllocationPriceConverter))] +public record class LicenseAllocationPrice : ModelBase { public object? Value { get; } = null; @@ -977,75 +993,115 @@ public string ItemID get { return Match( - newPlanUnit: (x) => x.ItemID, - newPlanTiered: (x) => x.ItemID, - newPlanBulk: (x) => x.ItemID, + unit: (x) => x.ItemID, + tiered: (x) => x.ItemID, + bulk: (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, + package: (x) => x.ItemID, + matrix: (x) => x.ItemID, + thresholdTotalAmount: (x) => x.ItemID, + tieredPackage: (x) => x.ItemID, + tieredWithMinimum: (x) => x.ItemID, + groupedTiered: (x) => x.ItemID, + tieredPackageWithMinimum: (x) => x.ItemID, + packageWithAllocation: (x) => x.ItemID, + unitWithPercent: (x) => x.ItemID, + matrixWithAllocation: (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, + unitWithProration: (x) => x.ItemID, + groupedAllocation: (x) => x.ItemID, + bulkWithProration: (x) => x.ItemID, + groupedWithProratedMinimum: (x) => x.ItemID, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.ItemID, + groupedTieredPackage: (x) => x.ItemID, + maxGroupTieredPackage: (x) => x.ItemID, + scalableMatrixWithUnitPricing: (x) => x.ItemID, + scalableMatrixWithTieredPricing: (x) => x.ItemID, + cumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - newPlanMinimumComposite: (x) => x.ItemID, + minimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID ); } } + public JsonElement ModelType + { + get + { + return Match( + unit: (x) => x.ModelType, + tiered: (x) => x.ModelType, + bulk: (x) => x.ModelType, + bulkWithFilters: (x) => x.ModelType, + package: (x) => x.ModelType, + matrix: (x) => x.ModelType, + thresholdTotalAmount: (x) => x.ModelType, + tieredPackage: (x) => x.ModelType, + tieredWithMinimum: (x) => x.ModelType, + groupedTiered: (x) => x.ModelType, + tieredPackageWithMinimum: (x) => x.ModelType, + packageWithAllocation: (x) => x.ModelType, + unitWithPercent: (x) => x.ModelType, + matrixWithAllocation: (x) => x.ModelType, + tieredWithProration: (x) => x.ModelType, + unitWithProration: (x) => x.ModelType, + groupedAllocation: (x) => x.ModelType, + bulkWithProration: (x) => x.ModelType, + groupedWithProratedMinimum: (x) => x.ModelType, + groupedWithMeteredMinimum: (x) => x.ModelType, + groupedWithMinMaxThresholds: (x) => x.ModelType, + matrixWithDisplayName: (x) => x.ModelType, + groupedTieredPackage: (x) => x.ModelType, + maxGroupTieredPackage: (x) => x.ModelType, + scalableMatrixWithUnitPricing: (x) => x.ModelType, + scalableMatrixWithTieredPricing: (x) => x.ModelType, + cumulativeGroupedBulk: (x) => x.ModelType, + cumulativeGroupedAllocation: (x) => x.ModelType, + minimumComposite: (x) => x.ModelType, + percent: (x) => x.ModelType, + eventOutput: (x) => x.ModelType + ); + } + } + public string Name { get { return Match( - newPlanUnit: (x) => x.Name, - newPlanTiered: (x) => x.Name, - newPlanBulk: (x) => x.Name, + unit: (x) => x.Name, + tiered: (x) => x.Name, + bulk: (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, + package: (x) => x.Name, + matrix: (x) => x.Name, + thresholdTotalAmount: (x) => x.Name, + tieredPackage: (x) => x.Name, + tieredWithMinimum: (x) => x.Name, + groupedTiered: (x) => x.Name, + tieredPackageWithMinimum: (x) => x.Name, + packageWithAllocation: (x) => x.Name, + unitWithPercent: (x) => x.Name, + matrixWithAllocation: (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, + unitWithProration: (x) => x.Name, + groupedAllocation: (x) => x.Name, + bulkWithProration: (x) => x.Name, + groupedWithProratedMinimum: (x) => x.Name, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.Name, + groupedTieredPackage: (x) => x.Name, + maxGroupTieredPackage: (x) => x.Name, + scalableMatrixWithUnitPricing: (x) => x.Name, + scalableMatrixWithTieredPricing: (x) => x.Name, + cumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, + minimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name ); @@ -1057,35 +1113,35 @@ public string? BillableMetricID get { return Match( - newPlanUnit: (x) => x.BillableMetricID, - newPlanTiered: (x) => x.BillableMetricID, - newPlanBulk: (x) => x.BillableMetricID, + unit: (x) => x.BillableMetricID, + tiered: (x) => x.BillableMetricID, + bulk: (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, + package: (x) => x.BillableMetricID, + matrix: (x) => x.BillableMetricID, + thresholdTotalAmount: (x) => x.BillableMetricID, + tieredPackage: (x) => x.BillableMetricID, + tieredWithMinimum: (x) => x.BillableMetricID, + groupedTiered: (x) => x.BillableMetricID, + tieredPackageWithMinimum: (x) => x.BillableMetricID, + packageWithAllocation: (x) => x.BillableMetricID, + unitWithPercent: (x) => x.BillableMetricID, + matrixWithAllocation: (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, + unitWithProration: (x) => x.BillableMetricID, + groupedAllocation: (x) => x.BillableMetricID, + bulkWithProration: (x) => x.BillableMetricID, + groupedWithProratedMinimum: (x) => x.BillableMetricID, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.BillableMetricID, + groupedTieredPackage: (x) => x.BillableMetricID, + maxGroupTieredPackage: (x) => x.BillableMetricID, + scalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + scalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + cumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, + minimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID ); @@ -1097,35 +1153,35 @@ public bool? BilledInAdvance get { return Match( - newPlanUnit: (x) => x.BilledInAdvance, - newPlanTiered: (x) => x.BilledInAdvance, - newPlanBulk: (x) => x.BilledInAdvance, + unit: (x) => x.BilledInAdvance, + tiered: (x) => x.BilledInAdvance, + bulk: (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, + package: (x) => x.BilledInAdvance, + matrix: (x) => x.BilledInAdvance, + thresholdTotalAmount: (x) => x.BilledInAdvance, + tieredPackage: (x) => x.BilledInAdvance, + tieredWithMinimum: (x) => x.BilledInAdvance, + groupedTiered: (x) => x.BilledInAdvance, + tieredPackageWithMinimum: (x) => x.BilledInAdvance, + packageWithAllocation: (x) => x.BilledInAdvance, + unitWithPercent: (x) => x.BilledInAdvance, + matrixWithAllocation: (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, + unitWithProration: (x) => x.BilledInAdvance, + groupedAllocation: (x) => x.BilledInAdvance, + bulkWithProration: (x) => x.BilledInAdvance, + groupedWithProratedMinimum: (x) => x.BilledInAdvance, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.BilledInAdvance, + groupedTieredPackage: (x) => x.BilledInAdvance, + maxGroupTieredPackage: (x) => x.BilledInAdvance, + scalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + scalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + cumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, + minimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance ); @@ -1137,35 +1193,35 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration get { return Match( - newPlanUnit: (x) => x.BillingCycleConfiguration, - newPlanTiered: (x) => x.BillingCycleConfiguration, - newPlanBulk: (x) => x.BillingCycleConfiguration, + unit: (x) => x.BillingCycleConfiguration, + tiered: (x) => x.BillingCycleConfiguration, + bulk: (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, + package: (x) => x.BillingCycleConfiguration, + matrix: (x) => x.BillingCycleConfiguration, + thresholdTotalAmount: (x) => x.BillingCycleConfiguration, + tieredPackage: (x) => x.BillingCycleConfiguration, + tieredWithMinimum: (x) => x.BillingCycleConfiguration, + groupedTiered: (x) => x.BillingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + packageWithAllocation: (x) => x.BillingCycleConfiguration, + unitWithPercent: (x) => x.BillingCycleConfiguration, + matrixWithAllocation: (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, + unitWithProration: (x) => x.BillingCycleConfiguration, + groupedAllocation: (x) => x.BillingCycleConfiguration, + bulkWithProration: (x) => x.BillingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.BillingCycleConfiguration, + groupedTieredPackage: (x) => x.BillingCycleConfiguration, + maxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, + minimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration ); @@ -1177,35 +1233,35 @@ public double? ConversionRate get { return Match( - newPlanUnit: (x) => x.ConversionRate, - newPlanTiered: (x) => x.ConversionRate, - newPlanBulk: (x) => x.ConversionRate, + unit: (x) => x.ConversionRate, + tiered: (x) => x.ConversionRate, + bulk: (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, + package: (x) => x.ConversionRate, + matrix: (x) => x.ConversionRate, + thresholdTotalAmount: (x) => x.ConversionRate, + tieredPackage: (x) => x.ConversionRate, + tieredWithMinimum: (x) => x.ConversionRate, + groupedTiered: (x) => x.ConversionRate, + tieredPackageWithMinimum: (x) => x.ConversionRate, + packageWithAllocation: (x) => x.ConversionRate, + unitWithPercent: (x) => x.ConversionRate, + matrixWithAllocation: (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, + unitWithProration: (x) => x.ConversionRate, + groupedAllocation: (x) => x.ConversionRate, + bulkWithProration: (x) => x.ConversionRate, + groupedWithProratedMinimum: (x) => x.ConversionRate, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.ConversionRate, + groupedTieredPackage: (x) => x.ConversionRate, + maxGroupTieredPackage: (x) => x.ConversionRate, + scalableMatrixWithUnitPricing: (x) => x.ConversionRate, + scalableMatrixWithTieredPricing: (x) => x.ConversionRate, + cumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, + minimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate ); @@ -1217,35 +1273,35 @@ public string? Currency get { return Match( - newPlanUnit: (x) => x.Currency, - newPlanTiered: (x) => x.Currency, - newPlanBulk: (x) => x.Currency, + unit: (x) => x.Currency, + tiered: (x) => x.Currency, + bulk: (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, + package: (x) => x.Currency, + matrix: (x) => x.Currency, + thresholdTotalAmount: (x) => x.Currency, + tieredPackage: (x) => x.Currency, + tieredWithMinimum: (x) => x.Currency, + groupedTiered: (x) => x.Currency, + tieredPackageWithMinimum: (x) => x.Currency, + packageWithAllocation: (x) => x.Currency, + unitWithPercent: (x) => x.Currency, + matrixWithAllocation: (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, + unitWithProration: (x) => x.Currency, + groupedAllocation: (x) => x.Currency, + bulkWithProration: (x) => x.Currency, + groupedWithProratedMinimum: (x) => x.Currency, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.Currency, + groupedTieredPackage: (x) => x.Currency, + maxGroupTieredPackage: (x) => x.Currency, + scalableMatrixWithUnitPricing: (x) => x.Currency, + scalableMatrixWithTieredPricing: (x) => x.Currency, + cumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, + minimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency ); @@ -1257,35 +1313,35 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration get { return Match( - newPlanUnit: (x) => x.DimensionalPriceConfiguration, - newPlanTiered: (x) => x.DimensionalPriceConfiguration, - newPlanBulk: (x) => x.DimensionalPriceConfiguration, + unit: (x) => x.DimensionalPriceConfiguration, + tiered: (x) => x.DimensionalPriceConfiguration, + bulk: (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, + package: (x) => x.DimensionalPriceConfiguration, + matrix: (x) => x.DimensionalPriceConfiguration, + thresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + tieredPackage: (x) => x.DimensionalPriceConfiguration, + tieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + groupedTiered: (x) => x.DimensionalPriceConfiguration, + tieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + packageWithAllocation: (x) => x.DimensionalPriceConfiguration, + unitWithPercent: (x) => x.DimensionalPriceConfiguration, + matrixWithAllocation: (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, + unitWithProration: (x) => x.DimensionalPriceConfiguration, + groupedAllocation: (x) => x.DimensionalPriceConfiguration, + bulkWithProration: (x) => x.DimensionalPriceConfiguration, + groupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + groupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + maxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + minimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration ); @@ -1297,35 +1353,35 @@ public string? ExternalPriceID get { return Match( - newPlanUnit: (x) => x.ExternalPriceID, - newPlanTiered: (x) => x.ExternalPriceID, - newPlanBulk: (x) => x.ExternalPriceID, + unit: (x) => x.ExternalPriceID, + tiered: (x) => x.ExternalPriceID, + bulk: (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, + package: (x) => x.ExternalPriceID, + matrix: (x) => x.ExternalPriceID, + thresholdTotalAmount: (x) => x.ExternalPriceID, + tieredPackage: (x) => x.ExternalPriceID, + tieredWithMinimum: (x) => x.ExternalPriceID, + groupedTiered: (x) => x.ExternalPriceID, + tieredPackageWithMinimum: (x) => x.ExternalPriceID, + packageWithAllocation: (x) => x.ExternalPriceID, + unitWithPercent: (x) => x.ExternalPriceID, + matrixWithAllocation: (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, + unitWithProration: (x) => x.ExternalPriceID, + groupedAllocation: (x) => x.ExternalPriceID, + bulkWithProration: (x) => x.ExternalPriceID, + groupedWithProratedMinimum: (x) => x.ExternalPriceID, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.ExternalPriceID, + groupedTieredPackage: (x) => x.ExternalPriceID, + maxGroupTieredPackage: (x) => x.ExternalPriceID, + scalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + scalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + cumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, + minimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID ); @@ -1337,35 +1393,35 @@ public double? FixedPriceQuantity get { return Match( - newPlanUnit: (x) => x.FixedPriceQuantity, - newPlanTiered: (x) => x.FixedPriceQuantity, - newPlanBulk: (x) => x.FixedPriceQuantity, + unit: (x) => x.FixedPriceQuantity, + tiered: (x) => x.FixedPriceQuantity, + bulk: (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, + package: (x) => x.FixedPriceQuantity, + matrix: (x) => x.FixedPriceQuantity, + thresholdTotalAmount: (x) => x.FixedPriceQuantity, + tieredPackage: (x) => x.FixedPriceQuantity, + tieredWithMinimum: (x) => x.FixedPriceQuantity, + groupedTiered: (x) => x.FixedPriceQuantity, + tieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + packageWithAllocation: (x) => x.FixedPriceQuantity, + unitWithPercent: (x) => x.FixedPriceQuantity, + matrixWithAllocation: (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, + unitWithProration: (x) => x.FixedPriceQuantity, + groupedAllocation: (x) => x.FixedPriceQuantity, + bulkWithProration: (x) => x.FixedPriceQuantity, + groupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.FixedPriceQuantity, + groupedTieredPackage: (x) => x.FixedPriceQuantity, + maxGroupTieredPackage: (x) => x.FixedPriceQuantity, + scalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + scalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + cumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + minimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity ); @@ -1377,35 +1433,35 @@ public string? InvoiceGroupingKey get { return Match( - newPlanUnit: (x) => x.InvoiceGroupingKey, - newPlanTiered: (x) => x.InvoiceGroupingKey, - newPlanBulk: (x) => x.InvoiceGroupingKey, + unit: (x) => x.InvoiceGroupingKey, + tiered: (x) => x.InvoiceGroupingKey, + bulk: (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, + package: (x) => x.InvoiceGroupingKey, + matrix: (x) => x.InvoiceGroupingKey, + thresholdTotalAmount: (x) => x.InvoiceGroupingKey, + tieredPackage: (x) => x.InvoiceGroupingKey, + tieredWithMinimum: (x) => x.InvoiceGroupingKey, + groupedTiered: (x) => x.InvoiceGroupingKey, + tieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + packageWithAllocation: (x) => x.InvoiceGroupingKey, + unitWithPercent: (x) => x.InvoiceGroupingKey, + matrixWithAllocation: (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, + unitWithProration: (x) => x.InvoiceGroupingKey, + groupedAllocation: (x) => x.InvoiceGroupingKey, + bulkWithProration: (x) => x.InvoiceGroupingKey, + groupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.InvoiceGroupingKey, + groupedTieredPackage: (x) => x.InvoiceGroupingKey, + maxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + scalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + scalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + cumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey ); @@ -1417,35 +1473,35 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration get { return Match( - newPlanUnit: (x) => x.InvoicingCycleConfiguration, - newPlanTiered: (x) => x.InvoicingCycleConfiguration, - newPlanBulk: (x) => x.InvoicingCycleConfiguration, + unit: (x) => x.InvoicingCycleConfiguration, + tiered: (x) => x.InvoicingCycleConfiguration, + bulk: (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, + package: (x) => x.InvoicingCycleConfiguration, + matrix: (x) => x.InvoicingCycleConfiguration, + thresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + tieredPackage: (x) => x.InvoicingCycleConfiguration, + tieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + groupedTiered: (x) => x.InvoicingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + packageWithAllocation: (x) => x.InvoicingCycleConfiguration, + unitWithPercent: (x) => x.InvoicingCycleConfiguration, + matrixWithAllocation: (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, + unitWithProration: (x) => x.InvoicingCycleConfiguration, + groupedAllocation: (x) => x.InvoicingCycleConfiguration, + bulkWithProration: (x) => x.InvoicingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + groupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + maxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + minimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration ); @@ -1457,35 +1513,35 @@ public string? LicenseTypeID get { return Match( - newPlanUnit: (x) => x.LicenseTypeID, - newPlanTiered: (x) => x.LicenseTypeID, - newPlanBulk: (x) => x.LicenseTypeID, + unit: (x) => x.LicenseTypeID, + tiered: (x) => x.LicenseTypeID, + bulk: (x) => x.LicenseTypeID, bulkWithFilters: (x) => x.LicenseTypeID, - newPlanPackage: (x) => x.LicenseTypeID, - newPlanMatrix: (x) => x.LicenseTypeID, - newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, - newPlanTieredPackage: (x) => x.LicenseTypeID, - newPlanTieredWithMinimum: (x) => x.LicenseTypeID, - newPlanGroupedTiered: (x) => x.LicenseTypeID, - newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, - newPlanPackageWithAllocation: (x) => x.LicenseTypeID, - newPlanUnitWithPercent: (x) => x.LicenseTypeID, - newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + package: (x) => x.LicenseTypeID, + matrix: (x) => x.LicenseTypeID, + thresholdTotalAmount: (x) => x.LicenseTypeID, + tieredPackage: (x) => x.LicenseTypeID, + tieredWithMinimum: (x) => x.LicenseTypeID, + groupedTiered: (x) => x.LicenseTypeID, + tieredPackageWithMinimum: (x) => x.LicenseTypeID, + packageWithAllocation: (x) => x.LicenseTypeID, + unitWithPercent: (x) => x.LicenseTypeID, + matrixWithAllocation: (x) => x.LicenseTypeID, tieredWithProration: (x) => x.LicenseTypeID, - newPlanUnitWithProration: (x) => x.LicenseTypeID, - newPlanGroupedAllocation: (x) => x.LicenseTypeID, - newPlanBulkWithProration: (x) => x.LicenseTypeID, - newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, - newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + unitWithProration: (x) => x.LicenseTypeID, + groupedAllocation: (x) => x.LicenseTypeID, + bulkWithProration: (x) => x.LicenseTypeID, + groupedWithProratedMinimum: (x) => x.LicenseTypeID, + groupedWithMeteredMinimum: (x) => x.LicenseTypeID, groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, - newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, - newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, - newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, - newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, - newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, - newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + matrixWithDisplayName: (x) => x.LicenseTypeID, + groupedTieredPackage: (x) => x.LicenseTypeID, + maxGroupTieredPackage: (x) => x.LicenseTypeID, + scalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + scalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + cumulativeGroupedBulk: (x) => x.LicenseTypeID, cumulativeGroupedAllocation: (x) => x.LicenseTypeID, - newPlanMinimumComposite: (x) => x.LicenseTypeID, + minimumComposite: (x) => x.LicenseTypeID, percent: (x) => x.LicenseTypeID, eventOutput: (x) => x.LicenseTypeID ); @@ -1497,292 +1553,295 @@ public string? ReferenceID get { return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, + unit: (x) => x.ReferenceID, + tiered: (x) => x.ReferenceID, + bulk: (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, + package: (x) => x.ReferenceID, + matrix: (x) => x.ReferenceID, + thresholdTotalAmount: (x) => x.ReferenceID, + tieredPackage: (x) => x.ReferenceID, + tieredWithMinimum: (x) => x.ReferenceID, + groupedTiered: (x) => x.ReferenceID, + tieredPackageWithMinimum: (x) => x.ReferenceID, + packageWithAllocation: (x) => x.ReferenceID, + unitWithPercent: (x) => x.ReferenceID, + matrixWithAllocation: (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, + unitWithProration: (x) => x.ReferenceID, + groupedAllocation: (x) => x.ReferenceID, + bulkWithProration: (x) => x.ReferenceID, + groupedWithProratedMinimum: (x) => x.ReferenceID, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.ReferenceID, + groupedTieredPackage: (x) => x.ReferenceID, + maxGroupTieredPackage: (x) => x.ReferenceID, + scalableMatrixWithUnitPricing: (x) => x.ReferenceID, + scalableMatrixWithTieredPricing: (x) => x.ReferenceID, + cumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, + minimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID ); } } - public Price(NewPlanUnitPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Unit value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Tiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Bulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(BulkWithFilters value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(Package value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Matrix value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + public LicenseAllocationPrice(ThresholdTotalAmount value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackageWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(PackageWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithPercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(TieredWithProration value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithProratedMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithMeteredMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(GroupedWithMinMaxThresholds value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithDisplayName value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MaxGroupTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice(ScalableMatrixWithUnitPricing value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanScalableMatrixWithTieredPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice( + ScalableMatrixWithTieredPricing value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice(CumulativeGroupedBulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(CumulativeGroupedAllocation value, JsonElement? element = null) + public LicenseAllocationPrice(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MinimumComposite value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(Percent value, JsonElement? element = null) + public LicenseAllocationPrice(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(EventOutput value, JsonElement? element = null) + public LicenseAllocationPrice(EventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(JsonElement element) + public LicenseAllocationPrice(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.TryPickNewPlanUnit(out var value)) { - /// // `value` is of type `NewPlanUnitPrice` + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `Unit` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + public bool TryPickUnit([NotNullWhen(true)] out Unit? value) { - value = this.Value as NewPlanUnitPrice; + value = this.Value as Unit; 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.TryPickTiered(out var value)) { + /// // `value` is of type `Tiered` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + public bool TryPickTiered([NotNullWhen(true)] out Tiered? value) { - value = this.Value as NewPlanTieredPrice; + value = this.Value as Tiered; 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.TryPickBulk(out var value)) { + /// // `value` is of type `Bulk` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + public bool TryPickBulk([NotNullWhen(true)] out Bulk? value) { - value = this.Value as NewPlanBulkPrice; + value = this.Value as Bulk; return value != null; } @@ -1809,227 +1868,213 @@ public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? valu /// /// 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.TryPickPackage(out var value)) { + /// // `value` is of type `Package` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + public bool TryPickPackage([NotNullWhen(true)] out Package? value) { - value = this.Value as NewPlanPackagePrice; + value = this.Value as Package; 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.TryPickMatrix(out var value)) { + /// // `value` is of type `Matrix` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + public bool TryPickMatrix([NotNullWhen(true)] out Matrix? value) { - value = this.Value as NewPlanMatrixPrice; + value = this.Value as Matrix; 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.TryPickThresholdTotalAmount(out var value)) { + /// // `value` is of type `ThresholdTotalAmount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) + public bool TryPickThresholdTotalAmount([NotNullWhen(true)] out ThresholdTotalAmount? value) { - value = this.Value as NewPlanThresholdTotalAmountPrice; + value = this.Value as ThresholdTotalAmount; 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.TryPickTieredPackage(out var value)) { + /// // `value` is of type `TieredPackage` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredPackage( - [NotNullWhen(true)] out NewPlanTieredPackagePrice? value - ) + public bool TryPickTieredPackage([NotNullWhen(true)] out TieredPackage? value) { - value = this.Value as NewPlanTieredPackagePrice; + value = this.Value as TieredPackage; 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.TryPickTieredWithMinimum(out var value)) { + /// // `value` is of type `TieredWithMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredWithMinimum( - [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value - ) + public bool TryPickTieredWithMinimum([NotNullWhen(true)] out TieredWithMinimum? value) { - value = this.Value as NewPlanTieredWithMinimumPrice; + value = this.Value as TieredWithMinimum; 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.TryPickGroupedTiered(out var value)) { + /// // `value` is of type `GroupedTiered` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value - ) + public bool TryPickGroupedTiered([NotNullWhen(true)] out GroupedTiered? value) { - value = this.Value as NewPlanGroupedTieredPrice; + value = this.Value as GroupedTiered; 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.TryPickTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `TieredPackageWithMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + public bool TryPickTieredPackageWithMinimum( + [NotNullWhen(true)] out TieredPackageWithMinimum? value ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; + value = this.Value as TieredPackageWithMinimum; 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.TryPickPackageWithAllocation(out var value)) { + /// // `value` is of type `PackageWithAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value - ) + public bool TryPickPackageWithAllocation([NotNullWhen(true)] out PackageWithAllocation? value) { - value = this.Value as NewPlanPackageWithAllocationPrice; + value = this.Value as PackageWithAllocation; 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.TryPickUnitWithPercent(out var value)) { + /// // `value` is of type `UnitWithPercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value - ) + public bool TryPickUnitWithPercent([NotNullWhen(true)] out UnitWithPercent? value) { - value = this.Value as NewPlanUnitWithPercentPrice; + value = this.Value as UnitWithPercent; 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.TryPickMatrixWithAllocation(out var value)) { + /// // `value` is of type `MatrixWithAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrixWithAllocation( - [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value - ) + public bool TryPickMatrixWithAllocation([NotNullWhen(true)] out MatrixWithAllocation? value) { - value = this.Value as NewPlanMatrixWithAllocationPrice; + value = this.Value as MatrixWithAllocation; return value != null; } @@ -2056,116 +2101,110 @@ public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProrati /// /// 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.TryPickUnitWithProration(out var value)) { + /// // `value` is of type `UnitWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public bool TryPickUnitWithProration([NotNullWhen(true)] out UnitWithProration? value) { - value = this.Value as NewPlanUnitWithProrationPrice; + value = this.Value as UnitWithProration; 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.TryPickGroupedAllocation(out var value)) { + /// // `value` is of type `GroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + public bool TryPickGroupedAllocation([NotNullWhen(true)] out GroupedAllocation? value) { - value = this.Value as NewPlanGroupedAllocationPrice; + value = this.Value as GroupedAllocation; 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.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` + /// if (instance.TryPickBulkWithProration(out var value)) { + /// // `value` is of type `BulkWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) + public bool TryPickBulkWithProration([NotNullWhen(true)] out BulkWithProration? value) { - value = this.Value as NewPlanBulkWithProrationPrice; + value = this.Value as BulkWithProration; 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.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` + /// if (instance.TryPickGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `GroupedWithProratedMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + public bool TryPickGroupedWithProratedMinimum( + [NotNullWhen(true)] out GroupedWithProratedMinimum? value ) { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; + value = this.Value as GroupedWithProratedMinimum; 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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` + /// if (instance.TryPickGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `GroupedWithMeteredMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + public bool TryPickGroupedWithMeteredMinimum( + [NotNullWhen(true)] out GroupedWithMeteredMinimum? value ) { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; + value = this.Value as GroupedWithMeteredMinimum; return value != null; } @@ -2194,139 +2233,131 @@ public bool TryPickGroupedWithMinMaxThresholds( /// /// 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.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` + /// if (instance.TryPickMatrixWithDisplayName(out var value)) { + /// // `value` is of type `MatrixWithDisplayName` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public bool TryPickMatrixWithDisplayName([NotNullWhen(true)] out MatrixWithDisplayName? value) { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; + value = this.Value as MatrixWithDisplayName; 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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` + /// if (instance.TryPickGroupedTieredPackage(out var value)) { + /// // `value` is of type `GroupedTieredPackage` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public bool TryPickGroupedTieredPackage([NotNullWhen(true)] out GroupedTieredPackage? value) { - value = this.Value as NewPlanGroupedTieredPackagePrice; + value = this.Value as GroupedTieredPackage; 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` + /// if (instance.TryPickMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `MaxGroupTieredPackage` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public bool TryPickMaxGroupTieredPackage([NotNullWhen(true)] out MaxGroupTieredPackage? value) { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; + value = this.Value as MaxGroupTieredPackage; 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.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` + /// if (instance.TryPickScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `ScalableMatrixWithUnitPricing` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value + public bool TryPickScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out ScalableMatrixWithUnitPricing? value ) { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; + value = this.Value as ScalableMatrixWithUnitPricing; 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.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` + /// if (instance.TryPickScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `ScalableMatrixWithTieredPricing` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value + public bool TryPickScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out ScalableMatrixWithTieredPricing? value ) { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; + value = this.Value as ScalableMatrixWithTieredPricing; 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.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` + /// if (instance.TryPickCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `CumulativeGroupedBulk` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public bool TryPickCumulativeGroupedBulk([NotNullWhen(true)] out CumulativeGroupedBulk? value) { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; + value = this.Value as CumulativeGroupedBulk; return value != null; } @@ -2355,24 +2386,22 @@ public bool TryPickCumulativeGroupedAllocation( /// /// 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.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` + /// if (instance.TryPickMinimumComposite(out var value)) { + /// // `value` is of type `MinimumComposite` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + public bool TryPickMinimumComposite([NotNullWhen(true)] out MinimumComposite? value) { - value = this.Value as NewPlanMinimumCompositePrice; + value = this.Value as MinimumComposite; return value != null; } @@ -2432,35 +2461,35 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// /// /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, + /// (Unit value) => {...}, + /// (Tiered value) => {...}, + /// (Bulk value) => {...}, /// (BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (Package value) => {...}, + /// (Matrix value) => {...}, + /// (ThresholdTotalAmount value) => {...}, + /// (TieredPackage value) => {...}, + /// (TieredWithMinimum value) => {...}, + /// (GroupedTiered value) => {...}, + /// (TieredPackageWithMinimum value) => {...}, + /// (PackageWithAllocation value) => {...}, + /// (UnitWithPercent value) => {...}, + /// (MatrixWithAllocation value) => {...}, /// (TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (UnitWithProration value) => {...}, + /// (GroupedAllocation value) => {...}, + /// (BulkWithProration value) => {...}, + /// (GroupedWithProratedMinimum value) => {...}, + /// (GroupedWithMeteredMinimum value) => {...}, /// (GroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (MatrixWithDisplayName value) => {...}, + /// (GroupedTieredPackage value) => {...}, + /// (MaxGroupTieredPackage value) => {...}, + /// (ScalableMatrixWithUnitPricing value) => {...}, + /// (ScalableMatrixWithTieredPricing value) => {...}, + /// (CumulativeGroupedBulk value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, + /// (MinimumComposite value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} /// ); @@ -2468,127 +2497,127 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// /// public void Switch( - System::Action newPlanUnit, - System::Action newPlanTiered, - System::Action newPlanBulk, + System::Action unit, + System::Action tiered, + System::Action bulk, 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 package, + System::Action matrix, + System::Action thresholdTotalAmount, + System::Action tieredPackage, + System::Action tieredWithMinimum, + System::Action groupedTiered, + System::Action tieredPackageWithMinimum, + System::Action packageWithAllocation, + System::Action unitWithPercent, + System::Action matrixWithAllocation, System::Action tieredWithProration, - System::Action newPlanUnitWithProration, - System::Action newPlanGroupedAllocation, - System::Action newPlanBulkWithProration, - System::Action newPlanGroupedWithProratedMinimum, - System::Action newPlanGroupedWithMeteredMinimum, + System::Action unitWithProration, + System::Action groupedAllocation, + System::Action bulkWithProration, + System::Action groupedWithProratedMinimum, + System::Action groupedWithMeteredMinimum, System::Action groupedWithMinMaxThresholds, - System::Action newPlanMatrixWithDisplayName, - System::Action newPlanGroupedTieredPackage, - System::Action newPlanMaxGroupTieredPackage, - System::Action newPlanScalableMatrixWithUnitPricing, - System::Action newPlanScalableMatrixWithTieredPricing, - System::Action newPlanCumulativeGroupedBulk, + System::Action matrixWithDisplayName, + System::Action groupedTieredPackage, + System::Action maxGroupTieredPackage, + System::Action scalableMatrixWithUnitPricing, + System::Action scalableMatrixWithTieredPricing, + System::Action cumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action newPlanMinimumComposite, + System::Action minimumComposite, System::Action percent, System::Action eventOutput ) { switch (this.Value) { - case NewPlanUnitPrice value: - newPlanUnit(value); + case Unit value: + unit(value); break; - case NewPlanTieredPrice value: - newPlanTiered(value); + case Tiered value: + tiered(value); break; - case NewPlanBulkPrice value: - newPlanBulk(value); + case Bulk value: + bulk(value); break; case BulkWithFilters value: bulkWithFilters(value); break; - case NewPlanPackagePrice value: - newPlanPackage(value); + case Package value: + package(value); break; - case NewPlanMatrixPrice value: - newPlanMatrix(value); + case Matrix value: + matrix(value); break; - case NewPlanThresholdTotalAmountPrice value: - newPlanThresholdTotalAmount(value); + case ThresholdTotalAmount value: + thresholdTotalAmount(value); break; - case NewPlanTieredPackagePrice value: - newPlanTieredPackage(value); + case TieredPackage value: + tieredPackage(value); break; - case NewPlanTieredWithMinimumPrice value: - newPlanTieredWithMinimum(value); + case TieredWithMinimum value: + tieredWithMinimum(value); break; - case NewPlanGroupedTieredPrice value: - newPlanGroupedTiered(value); + case GroupedTiered value: + groupedTiered(value); break; - case NewPlanTieredPackageWithMinimumPrice value: - newPlanTieredPackageWithMinimum(value); + case TieredPackageWithMinimum value: + tieredPackageWithMinimum(value); break; - case NewPlanPackageWithAllocationPrice value: - newPlanPackageWithAllocation(value); + case PackageWithAllocation value: + packageWithAllocation(value); break; - case NewPlanUnitWithPercentPrice value: - newPlanUnitWithPercent(value); + case UnitWithPercent value: + unitWithPercent(value); break; - case NewPlanMatrixWithAllocationPrice value: - newPlanMatrixWithAllocation(value); + case MatrixWithAllocation value: + matrixWithAllocation(value); break; case TieredWithProration value: tieredWithProration(value); break; - case NewPlanUnitWithProrationPrice value: - newPlanUnitWithProration(value); + case UnitWithProration value: + unitWithProration(value); break; - case NewPlanGroupedAllocationPrice value: - newPlanGroupedAllocation(value); + case GroupedAllocation value: + groupedAllocation(value); break; - case NewPlanBulkWithProrationPrice value: - newPlanBulkWithProration(value); + case BulkWithProration value: + bulkWithProration(value); break; - case NewPlanGroupedWithProratedMinimumPrice value: - newPlanGroupedWithProratedMinimum(value); + case GroupedWithProratedMinimum value: + groupedWithProratedMinimum(value); break; - case NewPlanGroupedWithMeteredMinimumPrice value: - newPlanGroupedWithMeteredMinimum(value); + case GroupedWithMeteredMinimum value: + groupedWithMeteredMinimum(value); break; case GroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; - case NewPlanMatrixWithDisplayNamePrice value: - newPlanMatrixWithDisplayName(value); + case MatrixWithDisplayName value: + matrixWithDisplayName(value); break; - case NewPlanGroupedTieredPackagePrice value: - newPlanGroupedTieredPackage(value); + case GroupedTieredPackage value: + groupedTieredPackage(value); break; - case NewPlanMaxGroupTieredPackagePrice value: - newPlanMaxGroupTieredPackage(value); + case MaxGroupTieredPackage value: + maxGroupTieredPackage(value); break; - case NewPlanScalableMatrixWithUnitPricingPrice value: - newPlanScalableMatrixWithUnitPricing(value); + case ScalableMatrixWithUnitPricing value: + scalableMatrixWithUnitPricing(value); break; - case NewPlanScalableMatrixWithTieredPricingPrice value: - newPlanScalableMatrixWithTieredPricing(value); + case ScalableMatrixWithTieredPricing value: + scalableMatrixWithTieredPricing(value); break; - case NewPlanCumulativeGroupedBulkPrice value: - newPlanCumulativeGroupedBulk(value); + case CumulativeGroupedBulk value: + cumulativeGroupedBulk(value); break; case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); + case MinimumComposite value: + minimumComposite(value); break; case Percent value: percent(value); @@ -2597,7 +2626,9 @@ public void Switch( eventOutput(value); break; default: - throw new OrbInvalidDataException("Data did not match any variant of Price"); + throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ); } } @@ -2616,35 +2647,35 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, + /// (Unit value) => {...}, + /// (Tiered value) => {...}, + /// (Bulk value) => {...}, /// (BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (Package value) => {...}, + /// (Matrix value) => {...}, + /// (ThresholdTotalAmount value) => {...}, + /// (TieredPackage value) => {...}, + /// (TieredWithMinimum value) => {...}, + /// (GroupedTiered value) => {...}, + /// (TieredPackageWithMinimum value) => {...}, + /// (PackageWithAllocation value) => {...}, + /// (UnitWithPercent value) => {...}, + /// (MatrixWithAllocation value) => {...}, /// (TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (UnitWithProration value) => {...}, + /// (GroupedAllocation value) => {...}, + /// (BulkWithProration value) => {...}, + /// (GroupedWithProratedMinimum value) => {...}, + /// (GroupedWithMeteredMinimum value) => {...}, /// (GroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (MatrixWithDisplayName value) => {...}, + /// (GroupedTieredPackage value) => {...}, + /// (MaxGroupTieredPackage value) => {...}, + /// (ScalableMatrixWithUnitPricing value) => {...}, + /// (ScalableMatrixWithTieredPricing value) => {...}, + /// (CumulativeGroupedBulk value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, + /// (MinimumComposite value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} /// ); @@ -2652,152 +2683,153 @@ public void Switch( /// /// public T Match( - System::Func newPlanUnit, - System::Func newPlanTiered, - System::Func newPlanBulk, + System::Func unit, + System::Func tiered, + System::Func bulk, 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 package, + System::Func matrix, + System::Func thresholdTotalAmount, + System::Func tieredPackage, + System::Func tieredWithMinimum, + System::Func groupedTiered, + System::Func tieredPackageWithMinimum, + System::Func packageWithAllocation, + System::Func unitWithPercent, + System::Func matrixWithAllocation, System::Func tieredWithProration, - System::Func newPlanUnitWithProration, - System::Func newPlanGroupedAllocation, - System::Func newPlanBulkWithProration, - System::Func newPlanGroupedWithProratedMinimum, - System::Func newPlanGroupedWithMeteredMinimum, + System::Func unitWithProration, + System::Func groupedAllocation, + System::Func bulkWithProration, + System::Func groupedWithProratedMinimum, + System::Func groupedWithMeteredMinimum, 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 matrixWithDisplayName, + System::Func groupedTieredPackage, + System::Func maxGroupTieredPackage, + System::Func scalableMatrixWithUnitPricing, + System::Func scalableMatrixWithTieredPricing, + System::Func cumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func newPlanMinimumComposite, + System::Func minimumComposite, System::Func percent, System::Func eventOutput ) { return this.Value switch { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), + Unit value => unit(value), + Tiered value => tiered(value), + Bulk value => bulk(value), BulkWithFilters 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), + Package value => package(value), + Matrix value => matrix(value), + ThresholdTotalAmount value => thresholdTotalAmount(value), + TieredPackage value => tieredPackage(value), + TieredWithMinimum value => tieredWithMinimum(value), + GroupedTiered value => groupedTiered(value), + TieredPackageWithMinimum value => tieredPackageWithMinimum(value), + PackageWithAllocation value => packageWithAllocation(value), + UnitWithPercent value => unitWithPercent(value), + MatrixWithAllocation value => matrixWithAllocation(value), TieredWithProration value => tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + UnitWithProration value => unitWithProration(value), + GroupedAllocation value => groupedAllocation(value), + BulkWithProration value => bulkWithProration(value), + GroupedWithProratedMinimum value => groupedWithProratedMinimum(value), + GroupedWithMeteredMinimum value => groupedWithMeteredMinimum(value), GroupedWithMinMaxThresholds 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), + MatrixWithDisplayName value => matrixWithDisplayName(value), + GroupedTieredPackage value => groupedTieredPackage(value), + MaxGroupTieredPackage value => maxGroupTieredPackage(value), + ScalableMatrixWithUnitPricing value => scalableMatrixWithUnitPricing(value), + ScalableMatrixWithTieredPricing value => scalableMatrixWithTieredPricing(value), + CumulativeGroupedBulk value => cumulativeGroupedBulk(value), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + MinimumComposite value => minimumComposite(value), Percent value => percent(value), EventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ), }; } - public static implicit operator Price(NewPlanUnitPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Unit value) => new(value); - public static implicit operator Price(NewPlanTieredPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Tiered value) => new(value); - public static implicit operator Price(NewPlanBulkPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Bulk value) => new(value); - public static implicit operator Price(BulkWithFilters value) => new(value); + public static implicit operator LicenseAllocationPrice(BulkWithFilters value) => new(value); - public static implicit operator Price(NewPlanPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Package value) => new(value); - public static implicit operator Price(NewPlanMatrixPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Matrix value) => new(value); - public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(ThresholdTotalAmount value) => + new(value); - public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackage value) => new(value); - public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithMinimum value) => new(value); - public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTiered value) => new(value); - public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackageWithMinimum value) => + new(value); - public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(PackageWithAllocation value) => + new(value); - public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithPercent value) => new(value); - public static implicit operator Price(NewPlanMatrixWithAllocationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MatrixWithAllocation value) => + new(value); - public static implicit operator Price(TieredWithProration value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithProration value) => new(value); - public static implicit operator Price(NewPlanUnitWithProrationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithProration value) => new(value); - public static implicit operator Price(NewPlanGroupedAllocationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedAllocation value) => new(value); - public static implicit operator Price(NewPlanBulkWithProrationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(BulkWithProration value) => new(value); - public static implicit operator Price(NewPlanGroupedWithProratedMinimumPrice value) => + public static implicit operator LicenseAllocationPrice(GroupedWithProratedMinimum value) => new(value); - public static implicit operator Price(NewPlanGroupedWithMeteredMinimumPrice value) => + public static implicit operator LicenseAllocationPrice(GroupedWithMeteredMinimum value) => new(value); - public static implicit operator Price(GroupedWithMinMaxThresholds value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedWithMinMaxThresholds value) => + new(value); - public static implicit operator Price(NewPlanMatrixWithDisplayNamePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MatrixWithDisplayName value) => + new(value); - public static implicit operator Price(NewPlanGroupedTieredPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTieredPackage value) => + new(value); - public static implicit operator Price(NewPlanMaxGroupTieredPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MaxGroupTieredPackage value) => + new(value); - public static implicit operator Price(NewPlanScalableMatrixWithUnitPricingPrice value) => + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithUnitPricing value) => new(value); - public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPrice value) => + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithTieredPricing value) => new(value); - public static implicit operator Price(NewPlanCumulativeGroupedBulkPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(CumulativeGroupedBulk value) => + new(value); - public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); + public static implicit operator LicenseAllocationPrice(CumulativeGroupedAllocation value) => + new(value); - public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MinimumComposite value) => new(value); - public static implicit operator Price(Percent value) => new(value); + public static implicit operator LicenseAllocationPrice(Percent value) => new(value); - public static implicit operator Price(EventOutput value) => new(value); + public static implicit operator LicenseAllocationPrice(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2813,46 +2845,46 @@ public override void Validate() { if (this.Value == null) { - throw new OrbInvalidDataException("Data did not match any variant of Price"); + throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ); } this.Switch( - (newPlanUnit) => newPlanUnit.Validate(), - (newPlanTiered) => newPlanTiered.Validate(), - (newPlanBulk) => newPlanBulk.Validate(), + (unit) => unit.Validate(), + (tiered) => tiered.Validate(), + (bulk) => bulk.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(), + (package) => package.Validate(), + (matrix) => matrix.Validate(), + (thresholdTotalAmount) => thresholdTotalAmount.Validate(), + (tieredPackage) => tieredPackage.Validate(), + (tieredWithMinimum) => tieredWithMinimum.Validate(), + (groupedTiered) => groupedTiered.Validate(), + (tieredPackageWithMinimum) => tieredPackageWithMinimum.Validate(), + (packageWithAllocation) => packageWithAllocation.Validate(), + (unitWithPercent) => unitWithPercent.Validate(), + (matrixWithAllocation) => matrixWithAllocation.Validate(), (tieredWithProration) => tieredWithProration.Validate(), - (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), - (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), - (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), - (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), - (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), + (unitWithProration) => unitWithProration.Validate(), + (groupedAllocation) => groupedAllocation.Validate(), + (bulkWithProration) => bulkWithProration.Validate(), + (groupedWithProratedMinimum) => groupedWithProratedMinimum.Validate(), + (groupedWithMeteredMinimum) => groupedWithMeteredMinimum.Validate(), (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), - (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), - (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), - (newPlanScalableMatrixWithUnitPricing) => - newPlanScalableMatrixWithUnitPricing.Validate(), - (newPlanScalableMatrixWithTieredPricing) => - newPlanScalableMatrixWithTieredPricing.Validate(), - (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), + (matrixWithDisplayName) => matrixWithDisplayName.Validate(), + (groupedTieredPackage) => groupedTieredPackage.Validate(), + (maxGroupTieredPackage) => maxGroupTieredPackage.Validate(), + (scalableMatrixWithUnitPricing) => scalableMatrixWithUnitPricing.Validate(), + (scalableMatrixWithTieredPricing) => scalableMatrixWithTieredPricing.Validate(), + (cumulativeGroupedBulk) => cumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (minimumComposite) => minimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(Price? other) => + public virtual bool Equals(LicenseAllocationPrice? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2872,35 +2904,35 @@ int VariantIndex() { return this.Value switch { - NewPlanUnitPrice _ => 0, - NewPlanTieredPrice _ => 1, - NewPlanBulkPrice _ => 2, + Unit _ => 0, + Tiered _ => 1, + Bulk _ => 2, BulkWithFilters _ => 3, - NewPlanPackagePrice _ => 4, - NewPlanMatrixPrice _ => 5, - NewPlanThresholdTotalAmountPrice _ => 6, - NewPlanTieredPackagePrice _ => 7, - NewPlanTieredWithMinimumPrice _ => 8, - NewPlanGroupedTieredPrice _ => 9, - NewPlanTieredPackageWithMinimumPrice _ => 10, - NewPlanPackageWithAllocationPrice _ => 11, - NewPlanUnitWithPercentPrice _ => 12, - NewPlanMatrixWithAllocationPrice _ => 13, + Package _ => 4, + Matrix _ => 5, + ThresholdTotalAmount _ => 6, + TieredPackage _ => 7, + TieredWithMinimum _ => 8, + GroupedTiered _ => 9, + TieredPackageWithMinimum _ => 10, + PackageWithAllocation _ => 11, + UnitWithPercent _ => 12, + MatrixWithAllocation _ => 13, TieredWithProration _ => 14, - NewPlanUnitWithProrationPrice _ => 15, - NewPlanGroupedAllocationPrice _ => 16, - NewPlanBulkWithProrationPrice _ => 17, - NewPlanGroupedWithProratedMinimumPrice _ => 18, - NewPlanGroupedWithMeteredMinimumPrice _ => 19, + UnitWithProration _ => 15, + GroupedAllocation _ => 16, + BulkWithProration _ => 17, + GroupedWithProratedMinimum _ => 18, + GroupedWithMeteredMinimum _ => 19, GroupedWithMinMaxThresholds _ => 20, - NewPlanMatrixWithDisplayNamePrice _ => 21, - NewPlanGroupedTieredPackagePrice _ => 22, - NewPlanMaxGroupTieredPackagePrice _ => 23, - NewPlanScalableMatrixWithUnitPricingPrice _ => 24, - NewPlanScalableMatrixWithTieredPricingPrice _ => 25, - NewPlanCumulativeGroupedBulkPrice _ => 26, + MatrixWithDisplayName _ => 21, + GroupedTieredPackage _ => 22, + MaxGroupTieredPackage _ => 23, + ScalableMatrixWithUnitPricing _ => 24, + ScalableMatrixWithTieredPricing _ => 25, + CumulativeGroupedBulk _ => 26, CumulativeGroupedAllocation _ => 27, - NewPlanMinimumCompositePrice _ => 28, + MinimumComposite _ => 28, Percent _ => 29, EventOutput _ => 30, _ => -1, @@ -2908,9 +2940,9 @@ int VariantIndex() } } -sealed class PriceConverter : JsonConverter +sealed class LicenseAllocationPriceConverter : JsonConverter { - public override Price? Read( + public override LicenseAllocationPrice? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2933,10 +2965,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2955,10 +2984,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2977,10 +3003,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3021,10 +3044,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3043,10 +3063,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3065,7 +3082,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3087,10 +3104,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3109,7 +3123,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3131,10 +3145,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3153,11 +3164,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3176,11 +3186,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3199,7 +3208,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3221,7 +3230,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3265,7 +3274,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3287,7 +3296,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3309,7 +3318,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3331,11 +3340,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3354,11 +3362,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3399,11 +3406,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3422,7 +3428,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3444,11 +3450,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3467,11 +3472,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3490,11 +3494,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3513,11 +3516,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3558,7 +3560,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3616,57 +3618,71 @@ JsonSerializerOptions options } default: { - return new Price(element); + return new LicenseAllocationPrice(element); } } } - public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + LicenseAllocationPrice? value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value?.Json, options); } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class BulkWithFilters : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Unit : JsonModel { /// - /// Configuration for bulk_with_filters pricing + /// The cadence to bill for this price on. /// - public required BulkWithFiltersConfig BulkWithFiltersConfig + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("bulk_with_filters_config"); + return this._rawData.GetNotNullClass>("cadence"); } - init { this._rawData.Set("bulk_with_filters_config", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The cadence to bill for this price on. + /// The id of the item the price will be associated with. /// - public required ApiEnum Cadence + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public required string ItemID + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("item_id", value); } } /// @@ -3695,6 +3711,19 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for unit pricing + /// + public required UnitConfig UnitConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_config"); + } + init { this._rawData.Set("unit_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -3899,19 +3928,18 @@ public string? ReferenceID /// public override void Validate() { - this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") - ) - ) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("unit"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.UnitConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -3928,349 +3956,186 @@ public override void Validate() _ = this.ReferenceID; } - public BulkWithFilters() + public Unit() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("unit"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public BulkWithFilters(BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } + public Unit(Unit unit) + : base(unit) { } #pragma warning restore CS8618 - public BulkWithFilters(IReadOnlyDictionary rawData) + public Unit(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("unit"); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFilters(FrozenDictionary rawData) + Unit(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Unit FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class UnitFromRaw : IFromRawJson { /// - public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => - BulkWithFilters.FromRawUnchecked(rawData); + public Unit FromRawUnchecked(IReadOnlyDictionary rawData) => + Unit.FromRawUnchecked(rawData); } /// -/// Configuration for bulk_with_filters pricing +/// The cadence to bill for this price on. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class BulkWithFiltersConfig : JsonModel +[JsonConverter(typeof(CadenceConverter))] +public enum Cadence { - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>("filters"); - } - init - { - this._rawData.Set>( - "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>("tiers"); - } - init - { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); - } - } + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - /// - public override void Validate() +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) + return JsonSerializer.Deserialize(ref reader, options) switch { - item.Validate(); - } - } - - public BulkWithFiltersConfig() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) - : base(bulkWithFiltersConfig) { } -#pragma warning restore CS8618 - - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), + }; } -#pragma warning restore CS8618 - /// - public static BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); } } -class BulkWithFiltersConfigFromRaw : IFromRawJson -{ - /// - public BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Filter : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseAllocation : JsonModel { /// - /// Event property key to filter on + /// The amount of credits granted per active license per cadence. /// - public required string PropertyKey + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("property_key", value); } + init { this._rawData.Set("amount", value); } } /// - /// Event property value to match + /// The currency of the license allocation. /// - public required string PropertyValue + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } - - public Filter() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public Filter(Filter filter) - : base(filter) { } -#pragma warning restore CS8618 - - public Filter(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Filter(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class FilterFromRaw : IFromRawJson -{ - /// - public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => - Filter.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Tier : 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); } + init { this._rawData.Set("currency", value); } } /// - /// The lower bound for this tier + /// When True, overage beyond the allocation is written off. /// - public string? TierLowerBound + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.UnitAmount; - _ = this.TierLowerBound; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public Tier() { } + public LicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public Tier(Tier tier) - : base(tier) { } + public LicenseAllocation(LicenseAllocation licenseAllocation) + : base(licenseAllocation) { } #pragma warning restore CS8618 - public Tier(IReadOnlyDictionary rawData) + public LicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Tier(FrozenDictionary rawData) + LicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static LicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class TierFromRaw : IFromRawJson +class LicenseAllocationFromRaw : IFromRawJson { /// - public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => - Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "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, Cadence value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); - } + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); } [JsonConverter(typeof(ConversionRateConfigConverter))] @@ -4562,20 +4427,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class TieredWithProration : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Tiered : 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); } } @@ -4593,6 +4456,29 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The pricing model type /// @@ -4620,18 +4506,16 @@ public required string Name } /// - /// Configuration for tiered_with_proration pricing + /// Configuration for tiered pricing /// - public required TieredWithProrationConfig TieredWithProrationConfig + public required TieredConfig TieredConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); + return this._rawData.GetNotNullClass("tiered_config"); } - init { this._rawData.Set("tiered_with_proration_config", value); } + init { this._rawData.Set("tiered_config", value); } } /// @@ -4693,12 +4577,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public TieredWithProrationConversionRateConfig? ConversionRateConfig + public TieredConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4842,17 +4726,16 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") - ) - ) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("tiered"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); + this.TieredConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -4869,53 +4752,51 @@ public override void Validate() _ = this.ReferenceID; } - public TieredWithProration() + public Tiered() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("tiered"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public TieredWithProration(TieredWithProration tieredWithProration) - : base(tieredWithProration) { } + public Tiered(Tiered tiered) + : base(tiered) { } #pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public Tiered(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("tiered"); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + Tiered(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tiered FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationFromRaw : IFromRawJson +class TieredFromRaw : IFromRawJson { /// - public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => - TieredWithProration.FromRawUnchecked(rawData); + public Tiered FromRawUnchecked(IReadOnlyDictionary rawData) => + Tiered.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(TieredCadenceConverter))] +public enum TieredCadence { Annual, SemiAnnual, @@ -4925,9 +4806,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter : JsonConverter +sealed class TieredCadenceConverter : JsonConverter { - public override TieredWithProrationCadence Read( + public override TieredCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4935,19 +4816,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => TieredWithProrationCadence.Annual, - "semi_annual" => TieredWithProrationCadence.SemiAnnual, - "monthly" => TieredWithProrationCadence.Monthly, - "quarterly" => TieredWithProrationCadence.Quarterly, - "one_time" => TieredWithProrationCadence.OneTime, - "custom" => TieredWithProrationCadence.Custom, - _ => (TieredWithProrationCadence)(-1), + "annual" => TieredCadence.Annual, + "semi_annual" => TieredCadence.SemiAnnual, + "monthly" => TieredCadence.Monthly, + "quarterly" => TieredCadence.Quarterly, + "one_time" => TieredCadence.OneTime, + "custom" => TieredCadence.Custom, + _ => (TieredCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - TieredWithProrationCadence value, + TieredCadence value, JsonSerializerOptions options ) { @@ -4955,12 +4836,12 @@ JsonSerializerOptions options writer, value switch { - TieredWithProrationCadence.Annual => "annual", - TieredWithProrationCadence.SemiAnnual => "semi_annual", - TieredWithProrationCadence.Monthly => "monthly", - TieredWithProrationCadence.Quarterly => "quarterly", - TieredWithProrationCadence.OneTime => "one_time", - TieredWithProrationCadence.Custom => "custom", + TieredCadence.Annual => "annual", + TieredCadence.SemiAnnual => "semi_annual", + TieredCadence.Monthly => "monthly", + TieredCadence.Quarterly => "quarterly", + TieredCadence.OneTime => "one_time", + TieredCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4970,156 +4851,79 @@ JsonSerializerOptions options } } -/// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class TieredWithProrationConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredLicenseAllocation : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// The amount of credits granted per active license per cadence. /// - public required IReadOnlyList Tiers + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); + return this._rawData.GetNotNullClass("amount"); } - init - { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public TieredWithProrationConfig() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) - : base(tieredWithProrationConfig) { } -#pragma warning restore CS8618 - - public TieredWithProrationConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + init { this._rawData.Set("amount", value); } } - [SetsRequiredMembers] - public TieredWithProrationConfig(IReadOnlyList tiers) - : this() - { - this.Tiers = tiers; - } -} - -class TieredWithProrationConfigFromRaw : IFromRawJson -{ - /// - public TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => TieredWithProrationConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single tiered with proration tier -/// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class TieredWithProrationConfigTier : JsonModel -{ /// - /// Inclusive tier starting value + /// The currency of the license allocation. /// - public required string TierLowerBound + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("currency", value); } } /// - /// Amount per unit + /// When True, overage beyond the allocation is written off. /// - public required string UnitAmount + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.TierLowerBound; - _ = this.UnitAmount; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public TieredWithProrationConfigTier() { } + public TieredLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public TieredWithProrationConfigTier( - TieredWithProrationConfigTier tieredWithProrationConfigTier - ) - : base(tieredWithProrationConfigTier) { } + public TieredLicenseAllocation(TieredLicenseAllocation tieredLicenseAllocation) + : base(tieredLicenseAllocation) { } #pragma warning restore CS8618 - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + public TieredLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfigTier(FrozenDictionary rawData) + TieredLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5127,16 +4931,16 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw : IFromRawJson +class TieredLicenseAllocationFromRaw : IFromRawJson { /// - public TieredWithProrationConfigTier FromRawUnchecked( + public TieredLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => TieredLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(TieredConversionRateConfigConverter))] +public record class TieredConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5153,7 +4957,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5162,7 +4966,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5171,7 +4975,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public TieredConversionRateConfig(JsonElement element) { this._element = element; } @@ -5253,7 +5057,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of TieredConversionRateConfig" ); } } @@ -5289,16 +5093,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of TieredConversionRateConfig" ), }; } - public static implicit operator TieredWithProrationConversionRateConfig( + public static implicit operator TieredConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator TieredWithProrationConversionRateConfig( + public static implicit operator TieredConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5317,13 +5121,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of TieredConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + public virtual bool Equals(TieredConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -5350,10 +5154,9 @@ int VariantIndex() } } -sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class TieredConversionRateConfigConverter : JsonConverter { - public override TieredWithProrationConversionRateConfig? Read( + public override TieredConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5418,14 +5221,14 @@ JsonSerializerOptions options } default: { - return new TieredWithProrationConversionRateConfig(element); + return new TieredConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - TieredWithProrationConversionRateConfig value, + TieredConversionRateConfig value, JsonSerializerOptions options ) { @@ -5433,39 +5236,33 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Bulk : JsonModel { /// - /// The cadence to bill for this price on. + /// Configuration for bulk pricing /// - public required ApiEnum Cadence + public required BulkConfig BulkConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass("bulk_config"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("bulk_config", value); } } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// The cadence to bill for this price on. /// - public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNotNullClass>("cadence"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("cadence", value); } } /// @@ -5481,6 +5278,29 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The pricing model type /// @@ -5566,12 +5386,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public BulkConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5713,15 +5533,14 @@ public string? ReferenceID /// public override void Validate() { + this.BulkConfig.Validate(); this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") - ) - ) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("bulk"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -5742,54 +5561,51 @@ public override void Validate() _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public Bulk() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("bulk"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) - : base(groupedWithMinMaxThresholds) { } + public Bulk(Bulk bulk) + : base(bulk) { } #pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public Bulk(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("bulk"); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + Bulk(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Bulk FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson +class BulkFromRaw : IFromRawJson { /// - public GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + public Bulk FromRawUnchecked(IReadOnlyDictionary rawData) => + Bulk.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(BulkCadenceConverter))] +public enum BulkCadence { Annual, SemiAnnual, @@ -5799,10 +5615,9 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class BulkCadenceConverter : JsonConverter { - public override GroupedWithMinMaxThresholdsCadence Read( + public override BulkCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5810,19 +5625,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, - "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => GroupedWithMinMaxThresholdsCadence.Custom, - _ => (GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => BulkCadence.Annual, + "semi_annual" => BulkCadence.SemiAnnual, + "monthly" => BulkCadence.Monthly, + "quarterly" => BulkCadence.Quarterly, + "one_time" => BulkCadence.OneTime, + "custom" => BulkCadence.Custom, + _ => (BulkCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCadence value, + BulkCadence value, JsonSerializerOptions options ) { @@ -5830,12 +5645,12 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMinMaxThresholdsCadence.Annual => "annual", - GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - GroupedWithMinMaxThresholdsCadence.Custom => "custom", + BulkCadence.Annual => "annual", + BulkCadence.SemiAnnual => "semi_annual", + BulkCadence.Monthly => "monthly", + BulkCadence.Quarterly => "quarterly", + BulkCadence.OneTime => "one_time", + BulkCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5845,103 +5660,79 @@ JsonSerializerOptions options } } -/// -/// Configuration for grouped_with_min_max_thresholds pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - GroupedWithMinMaxThresholdsConfig, - GroupedWithMinMaxThresholdsConfigFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkLicenseAllocation : 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 + /// The amount of credits granted per active license per cadence. /// - public required string MaximumCharge + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("amount", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The currency of the license allocation. /// - public required string MinimumCharge + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("currency", value); } } /// - /// The base price charged per group + /// When True, overage beyond the allocation is written off. /// - public required string PerUnitRate + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public GroupedWithMinMaxThresholdsConfig() { } + public BulkLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public GroupedWithMinMaxThresholdsConfig( - GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } + public BulkLicenseAllocation(BulkLicenseAllocation bulkLicenseAllocation) + : base(bulkLicenseAllocation) { } #pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public BulkLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + BulkLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static BulkLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5949,16 +5740,16 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson +class BulkLicenseAllocationFromRaw : IFromRawJson { /// - public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public BulkLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => BulkLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkConversionRateConfigConverter))] +public record class BulkConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5975,7 +5766,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5984,7 +5775,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5993,7 +5784,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public BulkConversionRateConfig(JsonElement element) { this._element = element; } @@ -6075,7 +5866,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of BulkConversionRateConfig" ); } } @@ -6111,16 +5902,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of BulkConversionRateConfig" ), }; } - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator BulkConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator BulkConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6139,13 +5930,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of BulkConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + public virtual bool Equals(BulkConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -6172,10 +5963,9 @@ int VariantIndex() } } -sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class BulkConversionRateConfigConverter : JsonConverter { - public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override BulkConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6240,14 +6030,14 @@ JsonSerializerOptions options } default: { - return new GroupedWithMinMaxThresholdsConversionRateConfig(element); + return new BulkConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsConversionRateConfig value, + BulkConversionRateConfig value, JsonSerializerOptions options ) { @@ -6255,39 +6045,35 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class CumulativeGroupedAllocation : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFilters : JsonModel { /// - /// The cadence to bill for this price on. + /// Configuration for bulk_with_filters pricing /// - public required ApiEnum Cadence + public required BulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass("bulk_with_filters_config"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("bulk_with_filters_config", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// The cadence to bill for this price on. /// - public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass>( + "cadence" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("cadence", value); } } /// @@ -6303,6 +6089,29 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The pricing model type /// @@ -6388,12 +6197,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public BulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6535,13 +6344,17 @@ public string? ReferenceID /// public override void Validate() { + this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("bulk_with_filters") ) ) { @@ -6564,34 +6377,126 @@ public override void Validate() _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public BulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) - : base(cumulativeGroupedAllocation) { } + public BulkWithFilters(BulkWithFilters bulkWithFilters) + : base(bulkWithFilters) { } #pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public BulkWithFilters(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + BulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocation FromRawUnchecked( + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithFiltersFromRaw : IFromRawJson +{ + /// + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("filters"); + } + init + { + this._rawData.Set>( + "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>("tiers"); + } + init + { + this._rawData.Set>( + "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 BulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) + : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public BulkWithFiltersConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithFiltersConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6599,19 +6504,174 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public CumulativeGroupedAllocation FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Filter : 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 Filter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) + : base(filter) { } +#pragma warning restore CS8618 + + public Filter(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Filter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FilterFromRaw : IFromRawJson +{ + /// + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Tier : 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 Tier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Tier(Tier tier) + : base(tier) { } +#pragma warning restore CS8618 + + public Tier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Tier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Tier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class TierFromRaw : IFromRawJson +{ + /// + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(BulkWithFiltersCadenceConverter))] +public enum BulkWithFiltersCadence { Annual, SemiAnnual, @@ -6621,10 +6681,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class BulkWithFiltersCadenceConverter : JsonConverter { - public override CumulativeGroupedAllocationCadence Read( + public override BulkWithFiltersCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6632,19 +6691,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, - "one_time" => CumulativeGroupedAllocationCadence.OneTime, - "custom" => CumulativeGroupedAllocationCadence.Custom, - _ => (CumulativeGroupedAllocationCadence)(-1), + "annual" => BulkWithFiltersCadence.Annual, + "semi_annual" => BulkWithFiltersCadence.SemiAnnual, + "monthly" => BulkWithFiltersCadence.Monthly, + "quarterly" => BulkWithFiltersCadence.Quarterly, + "one_time" => BulkWithFiltersCadence.OneTime, + "custom" => BulkWithFiltersCadence.Custom, + _ => (BulkWithFiltersCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCadence value, + BulkWithFiltersCadence value, JsonSerializerOptions options ) { @@ -6652,12 +6711,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCadence.Annual => "annual", - CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - CumulativeGroupedAllocationCadence.Monthly => "monthly", - CumulativeGroupedAllocationCadence.Quarterly => "quarterly", - CumulativeGroupedAllocationCadence.OneTime => "one_time", - CumulativeGroupedAllocationCadence.Custom => "custom", + BulkWithFiltersCadence.Annual => "annual", + BulkWithFiltersCadence.SemiAnnual => "semi_annual", + BulkWithFiltersCadence.Monthly => "monthly", + BulkWithFiltersCadence.Quarterly => "quarterly", + BulkWithFiltersCadence.OneTime => "one_time", + BulkWithFiltersCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6667,103 +6726,86 @@ JsonSerializerOptions options } } -/// -/// Configuration for cumulative_grouped_allocation pricing -/// [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedAllocationConfig, - CumulativeGroupedAllocationConfigFromRaw + BulkWithFiltersLicenseAllocation, + BulkWithFiltersLicenseAllocationFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class BulkWithFiltersLicenseAllocation : JsonModel { /// - /// The overall allocation across all groups + /// The amount of credits granted per active license per cadence. /// - public required string CumulativeAllocation + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("amount", value); } } /// - /// The allocation per individual group + /// The currency of the license allocation. /// - public required string GroupAllocation + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("currency", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// When True, overage beyond the allocation is written off. /// - public required string UnitAmount + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public CumulativeGroupedAllocationConfig() { } + public BulkWithFiltersLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public CumulativeGroupedAllocationConfig( - CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + public BulkWithFiltersLicenseAllocation( + BulkWithFiltersLicenseAllocation bulkWithFiltersLicenseAllocation ) - : base(cumulativeGroupedAllocationConfig) { } + : base(bulkWithFiltersLicenseAllocation) { } #pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public BulkWithFiltersLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + BulkWithFiltersLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static BulkWithFiltersLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6771,16 +6813,16 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +class BulkWithFiltersLicenseAllocationFromRaw : IFromRawJson { /// - public CumulativeGroupedAllocationConfig FromRawUnchecked( + public BulkWithFiltersLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkWithFiltersConversionRateConfigConverter))] +public record class BulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6797,7 +6839,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6806,7 +6848,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6815,7 +6857,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public BulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -6897,7 +6939,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of BulkWithFiltersConversionRateConfig" ); } } @@ -6933,16 +6975,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 BulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6961,13 +7003,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 BulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + public virtual bool Equals(BulkWithFiltersConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -6994,10 +7036,10 @@ int VariantIndex() } } -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class BulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override CumulativeGroupedAllocationConversionRateConfig? Read( + public override BulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7062,14 +7104,14 @@ JsonSerializerOptions options } default: { - return new CumulativeGroupedAllocationConversionRateConfig(element); + return new BulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationConversionRateConfig value, + BulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -7077,18 +7119,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Package : 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); } } @@ -7106,6 +7148,29 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The pricing model type /// @@ -7133,16 +7198,16 @@ public required string Name } /// - /// Configuration for percent pricing + /// Configuration for package pricing /// - public required PercentConfig PercentConfig + public required PackageConfig PackageConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("percent_config"); + return this._rawData.GetNotNullClass("package_config"); } - init { this._rawData.Set("percent_config", value); } + init { this._rawData.Set("package_config", value); } } /// @@ -7204,12 +7269,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PercentConversionRateConfig? ConversionRateConfig + public PackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7353,12 +7418,16 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("package"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); + this.PackageConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -7375,51 +7444,51 @@ public override void Validate() _ = this.ReferenceID; } - public Percent() + public Package() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("package"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public Percent(Percent percent) - : base(percent) { } + public Package(Package package) + : base(package) { } #pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public Package(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("package"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + Package(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Package FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PackageFromRaw : IFromRawJson { /// - public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => - Percent.FromRawUnchecked(rawData); + public Package FromRawUnchecked(IReadOnlyDictionary rawData) => + Package.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(PackageCadenceConverter))] +public enum PackageCadence { Annual, SemiAnnual, @@ -7429,9 +7498,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class PackageCadenceConverter : JsonConverter { - public override PercentCadence Read( + public override PackageCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7439,19 +7508,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PercentCadence.Annual, - "semi_annual" => PercentCadence.SemiAnnual, - "monthly" => PercentCadence.Monthly, - "quarterly" => PercentCadence.Quarterly, - "one_time" => PercentCadence.OneTime, - "custom" => PercentCadence.Custom, - _ => (PercentCadence)(-1), + "annual" => PackageCadence.Annual, + "semi_annual" => PackageCadence.SemiAnnual, + "monthly" => PackageCadence.Monthly, + "quarterly" => PackageCadence.Quarterly, + "one_time" => PackageCadence.OneTime, + "custom" => PackageCadence.Custom, + _ => (PackageCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PercentCadence value, + PackageCadence value, JsonSerializerOptions options ) { @@ -7459,12 +7528,12 @@ JsonSerializerOptions options writer, value switch { - PercentCadence.Annual => "annual", - PercentCadence.SemiAnnual => "semi_annual", - PercentCadence.Monthly => "monthly", - PercentCadence.Quarterly => "quarterly", - PercentCadence.OneTime => "one_time", - PercentCadence.Custom => "custom", + PackageCadence.Annual => "annual", + PackageCadence.SemiAnnual => "semi_annual", + PackageCadence.Monthly => "monthly", + PackageCadence.Quarterly => "quarterly", + PackageCadence.OneTime => "one_time", + PackageCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7474,75 +7543,98 @@ JsonSerializerOptions options } } -/// -/// Configuration for percent pricing -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PercentConfig : JsonModel +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PackageLicenseAllocation : JsonModel { /// - /// What percent of the component subtotals to charge + /// The amount of credits granted per active license per cadence. /// - public required double Percent + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public PercentConfig() { } + public PackageLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public PercentConfig(PercentConfig percentConfig) - : base(percentConfig) { } + public PackageLicenseAllocation(PackageLicenseAllocation packageLicenseAllocation) + : base(packageLicenseAllocation) { } #pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public PackageLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + PackageLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static PackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class PackageLicenseAllocationFromRaw : IFromRawJson { /// - public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - PercentConfig.FromRawUnchecked(rawData); + public PackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(PackageConversionRateConfigConverter))] +public record class PackageConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7559,7 +7651,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public PackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7568,7 +7660,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public PackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7577,7 +7669,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public PackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -7659,7 +7751,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of PackageConversionRateConfig" ); } } @@ -7695,16 +7787,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 PackageConversionRateConfig" ), }; } - public static implicit operator PercentConversionRateConfig( + public static implicit operator PackageConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PercentConversionRateConfig( + public static implicit operator PackageConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7723,13 +7815,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 PackageConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) => + public virtual bool Equals(PackageConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -7756,9 +7848,9 @@ int VariantIndex() } } -sealed class PercentConversionRateConfigConverter : JsonConverter +sealed class PackageConversionRateConfigConverter : JsonConverter { - public override PercentConversionRateConfig? Read( + public override PackageConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7823,14 +7915,14 @@ JsonSerializerOptions options } default: { - return new PercentConversionRateConfig(element); + return new PackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PercentConversionRateConfig value, + PackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -7838,46 +7930,69 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutput : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Matrix : 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); } } /// - /// Configuration for event_output pricing + /// The id of the item the price will be associated with. /// - public required EventOutputConfig EventOutputConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("event_output_config"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("event_output_config", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public required string ItemID + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("item_id", value); } + } + + /// + /// Configuration for matrix pricing + /// + public required MatrixConfig MatrixConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("matrix_config"); + } + init { this._rawData.Set("matrix_config", value); } } /// @@ -7965,12 +8080,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public EventOutputConversionRateConfig? ConversionRateConfig + public MatrixConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8113,14 +8228,13 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixConfig.Validate(); + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("matrix"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -8141,51 +8255,51 @@ public override void Validate() _ = this.ReferenceID; } - public EventOutput() + public Matrix() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("matrix"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public EventOutput(EventOutput eventOutput) - : base(eventOutput) { } + public Matrix(Matrix matrix) + : base(matrix) { } #pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public Matrix(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("matrix"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + Matrix(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Matrix FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputFromRaw : IFromRawJson +class MatrixFromRaw : IFromRawJson { /// - public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutput.FromRawUnchecked(rawData); + public Matrix FromRawUnchecked(IReadOnlyDictionary rawData) => + Matrix.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(MatrixCadenceConverter))] +public enum MatrixCadence { Annual, SemiAnnual, @@ -8195,9 +8309,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter : JsonConverter +sealed class MatrixCadenceConverter : JsonConverter { - public override EventOutputCadence Read( + public override MatrixCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8205,19 +8319,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => EventOutputCadence.Annual, - "semi_annual" => EventOutputCadence.SemiAnnual, - "monthly" => EventOutputCadence.Monthly, - "quarterly" => EventOutputCadence.Quarterly, - "one_time" => EventOutputCadence.OneTime, - "custom" => EventOutputCadence.Custom, - _ => (EventOutputCadence)(-1), + "annual" => MatrixCadence.Annual, + "semi_annual" => MatrixCadence.SemiAnnual, + "monthly" => MatrixCadence.Monthly, + "quarterly" => MatrixCadence.Quarterly, + "one_time" => MatrixCadence.OneTime, + "custom" => MatrixCadence.Custom, + _ => (MatrixCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - EventOutputCadence value, + MatrixCadence value, JsonSerializerOptions options ) { @@ -8225,12 +8339,12 @@ JsonSerializerOptions options writer, value switch { - EventOutputCadence.Annual => "annual", - EventOutputCadence.SemiAnnual => "semi_annual", - EventOutputCadence.Monthly => "monthly", - EventOutputCadence.Quarterly => "quarterly", - EventOutputCadence.OneTime => "one_time", - EventOutputCadence.Custom => "custom", + MatrixCadence.Annual => "annual", + MatrixCadence.SemiAnnual => "semi_annual", + MatrixCadence.Monthly => "monthly", + MatrixCadence.Quarterly => "quarterly", + MatrixCadence.OneTime => "one_time", + MatrixCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8240,108 +8354,96 @@ JsonSerializerOptions options } } -/// -/// Configuration for event_output pricing -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutputConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixLicenseAllocation : JsonModel { /// - /// The key in the event data to extract the unit rate from. + /// The amount of credits granted per active license per cadence. /// - public required string UnitRatingKey + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("unit_rating_key", value); } + init { this._rawData.Set("amount", 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. + /// The currency of the license allocation. /// - public string? DefaultUnitRate + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("default_unit_rate", value); } + init { this._rawData.Set("currency", 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. + /// When True, overage beyond the allocation is written off. /// - public string? GroupingKey + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public EventOutputConfig() { } + public MatrixLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public EventOutputConfig(EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } + public MatrixLicenseAllocation(MatrixLicenseAllocation matrixLicenseAllocation) + : base(matrixLicenseAllocation) { } #pragma warning restore CS8618 - public EventOutputConfig(IReadOnlyDictionary rawData) + public MatrixLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + MatrixLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static EventOutputConfig FromRawUnchecked( + /// + public static MatrixLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() - { - this.UnitRatingKey = unitRatingKey; - } } -class EventOutputConfigFromRaw : IFromRawJson +class MatrixLicenseAllocationFromRaw : IFromRawJson { /// - public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutputConfig.FromRawUnchecked(rawData); + public MatrixLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase +[JsonConverter(typeof(MatrixConversionRateConfigConverter))] +public record class MatrixConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8358,7 +8460,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public MatrixConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8367,7 +8469,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public MatrixConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8376,7 +8478,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public MatrixConversionRateConfig(JsonElement element) { this._element = element; } @@ -8458,7 +8560,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of MatrixConversionRateConfig" ); } } @@ -8494,16 +8596,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of MatrixConversionRateConfig" ), }; } - public static implicit operator EventOutputConversionRateConfig( + public static implicit operator MatrixConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator EventOutputConversionRateConfig( + public static implicit operator MatrixConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8522,13 +8624,13 @@ 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 MatrixConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) => + public virtual bool Equals(MatrixConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -8555,10 +8657,9 @@ int VariantIndex() } } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class MatrixConversionRateConfigConverter : JsonConverter { - public override EventOutputConversionRateConfig? Read( + public override MatrixConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8623,14 +8724,14 @@ JsonSerializerOptions options } default: { - return new EventOutputConversionRateConfig(element); + return new MatrixConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - EventOutputConversionRateConfig value, + MatrixConversionRateConfig value, JsonSerializerOptions options ) { @@ -8638,237 +8739,522 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdTotalAmount : JsonModel { /// - /// The id of the adjustment to remove from on the plan. + /// The cadence to bill for this price on. /// - public required string AdjustmentID + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } - init { this._rawData.Set("adjustment_id", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The phase to remove this adjustment from. + /// The id of the item the price will be associated with. /// - public long? PlanPhaseOrder + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("item_id", value); } } - /// - public override void Validate() + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations { - _ = this.AdjustmentID; - _ = this.PlanPhaseOrder; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } } - public RemoveAdjustment() { } + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } -#pragma warning restore CS8618 + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } - public RemoveAdjustment(IReadOnlyDictionary rawData) + /// + /// Configuration for threshold_total_amount pricing + /// + public required ThresholdTotalAmountConfig ThresholdTotalAmountConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "threshold_total_amount_config" + ); + } + init { this._rawData.Set("threshold_total_amount_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } -#pragma warning restore CS8618 - /// - public static RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary 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 { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.AdjustmentID = adjustmentID; + 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); -} + /// + /// 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); } + } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemovePrice : JsonModel -{ /// - /// The id of the price to remove from the plan. + /// The configuration for the rate of the price currency to the invoicing currency. /// - public required string PriceID + public ThresholdTotalAmountConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("conversion_rate_config", value); } } /// - /// The phase to remove this price from. + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. /// - public long? PlanPhaseOrder + public string? Currency { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableClass("currency"); } - init { this._rawData.Set("plan_phase_order", value); } + 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.PriceID; - _ = this.PlanPhaseOrder; + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("threshold_total_amount") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ThresholdTotalAmountConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; } - public RemovePrice() { } + public ThresholdTotalAmount() + { + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + } #pragma warning disable CS8618 [SetsRequiredMembers] - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } + public ThresholdTotalAmount(ThresholdTotalAmount thresholdTotalAmount) + : base(thresholdTotalAmount) { } #pragma warning restore CS8618 - public RemovePrice(IReadOnlyDictionary rawData) + public ThresholdTotalAmount(IReadOnlyDictionary rawData) { this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); } #pragma warning disable CS8618 [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + ThresholdTotalAmount(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static ThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() - { - this.PriceID = priceID; - } } -class RemovePriceFromRaw : IFromRawJson +class ThresholdTotalAmountFromRaw : IFromRawJson { /// - public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - RemovePrice.FromRawUnchecked(rawData); + public ThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmount.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplaceAdjustment : JsonModel +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ThresholdTotalAmountCadenceConverter))] +public enum ThresholdTotalAmountCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ThresholdTotalAmountCadenceConverter : JsonConverter +{ + public override ThresholdTotalAmountCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ThresholdTotalAmountCadence.Annual, + "semi_annual" => ThresholdTotalAmountCadence.SemiAnnual, + "monthly" => ThresholdTotalAmountCadence.Monthly, + "quarterly" => ThresholdTotalAmountCadence.Quarterly, + "one_time" => ThresholdTotalAmountCadence.OneTime, + "custom" => ThresholdTotalAmountCadence.Custom, + _ => (ThresholdTotalAmountCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ThresholdTotalAmountCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ThresholdTotalAmountCadence.Annual => "annual", + ThresholdTotalAmountCadence.SemiAnnual => "semi_annual", + ThresholdTotalAmountCadence.Monthly => "monthly", + ThresholdTotalAmountCadence.Quarterly => "quarterly", + ThresholdTotalAmountCadence.OneTime => "one_time", + ThresholdTotalAmountCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ThresholdTotalAmountLicenseAllocation, + ThresholdTotalAmountLicenseAllocationFromRaw + >) +)] +public sealed record class ThresholdTotalAmountLicenseAllocation : JsonModel { /// - /// The definition of a new adjustment to create and add to the plan. + /// The amount of credits granted per active license per cadence. /// - public required ReplaceAdjustmentAdjustment Adjustment + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("amount", value); } } /// - /// The id of the adjustment on the plan to replace in the plan. + /// The currency of the license allocation. /// - public required string ReplacesAdjustmentID + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("currency", value); } } /// - /// The phase to replace this adjustment from. + /// When True, overage beyond the allocation is written off. /// - public long? PlanPhaseOrder + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public ReplaceAdjustment() { } + public ThresholdTotalAmountLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } + public ThresholdTotalAmountLicenseAllocation( + ThresholdTotalAmountLicenseAllocation thresholdTotalAmountLicenseAllocation + ) + : base(thresholdTotalAmountLicenseAllocation) { } #pragma warning restore CS8618 - public ReplaceAdjustment(IReadOnlyDictionary rawData) + public ThresholdTotalAmountLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + ThresholdTotalAmountLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplaceAdjustment FromRawUnchecked( + /// + public static ThresholdTotalAmountLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8876,199 +9262,266 @@ IReadOnlyDictionary rawData } } -class ReplaceAdjustmentFromRaw : IFromRawJson +class ThresholdTotalAmountLicenseAllocationFromRaw + : IFromRawJson { /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); + public ThresholdTotalAmountLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmountLicenseAllocation.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the plan. +/// Configuration for threshold_total_amount pricing /// -[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class ThresholdTotalAmountConfig : JsonModel { - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json + /// + /// When the quantity consumed passes a provided threshold, the configured total + /// will be charged + /// + public required IReadOnlyList ConsumptionTable { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "consumption_table" ); } - } - - public string? Currency - { - get + init { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + this._rawData.Set>( + "consumption_table", + ImmutableArray.ToImmutableArray(value) ); } } - public bool? IsInvoiceLevel + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate { get { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); } + init { this._rawData.Set("prorate", value); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + foreach (var item in this.ConsumptionTable) + { + item.Validate(); + } + _ = this.Prorate; } - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + public ThresholdTotalAmountConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmountConfig(ThresholdTotalAmountConfig thresholdTotalAmountConfig) + : base(thresholdTotalAmountConfig) { } +#pragma warning restore CS8618 + + public ThresholdTotalAmountConfig(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdTotalAmountConfig(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + /// + public static ThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + [SetsRequiredMembers] + public ThresholdTotalAmountConfig(IReadOnlyList consumptionTable) + : this() { - this.Value = value; - this._element = element; + this.ConsumptionTable = consumptionTable; } +} - public ReplaceAdjustmentAdjustment(JsonElement element) +class ThresholdTotalAmountConfigFromRaw : IFromRawJson +{ + /// + public ThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmountConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single threshold +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ConsumptionTable : JsonModel +{ + public required string Threshold { - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold"); + } + init { this._rawData.Set("threshold", 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.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// + /// Total amount for this threshold /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public required string TotalAmount { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total_amount"); + } + init { this._rawData.Set("total_amount", 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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + /// + public override void Validate() { - value = this.Value as NewUsageDiscount; - return value != null; + _ = this.Threshold; + _ = this.TotalAmount; } - /// - /// 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 ConsumptionTable() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ConsumptionTable(ConsumptionTable consumptionTable) + : base(consumptionTable) { } +#pragma warning restore CS8618 + + public ConsumptionTable(IReadOnlyDictionary rawData) { - value = this.Value as NewAmountDiscount; - return value != null; + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ConsumptionTable(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ConsumptionTable FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ConsumptionTableFromRaw : IFromRawJson +{ + /// + public ConsumptionTable FromRawUnchecked(IReadOnlyDictionary rawData) => + ConsumptionTable.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ThresholdTotalAmountConversionRateConfigConverter))] +public record class ThresholdTotalAmountConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ThresholdTotalAmountConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ThresholdTotalAmountConversionRateConfig(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.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - value = this.Value as NewMinimum; + 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 . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - value = this.Value as NewMaximum; + value = this.Value as SharedTieredConversionRateConfig; return value != null; } @@ -9086,43 +9539,28 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// /// public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum + System::Action unit, + System::Action tiered ) { 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); + case SharedUnitConversionRateConfig value: + unit(value); break; - case NewMaximum value: - newMaximum(value); + case SharedTieredConversionRateConfig value: + tiered(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" + "Data did not match any variant of ThresholdTotalAmountConversionRateConfig" ); } } @@ -9142,48 +9580,34 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// /// public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum + System::Func unit, + System::Func tiered ) { return this.Value switch { - NewPercentageDiscount value => newPercentageDiscount(value), - NewUsageDiscount value => newUsageDiscount(value), - NewAmountDiscount value => newAmountDiscount(value), - NewMinimum value => newMinimum(value), - NewMaximum value => newMaximum(value), + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" + "Data did not match any variant of ThresholdTotalAmountConversionRateConfig" ), }; } - public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount 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 ThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); + public static implicit operator ThresholdTotalAmountConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -9200,19 +9624,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" + "Data did not match any variant of ThresholdTotalAmountConversionRateConfig" ); } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + public virtual bool Equals(ThresholdTotalAmountConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -9232,64 +9650,40 @@ int VariantIndex() { return this.Value switch { - NewPercentageDiscount _ => 0, - NewUsageDiscount _ => 1, - NewAmountDiscount _ => 2, - NewMinimum _ => 3, - NewMaximum _ => 4, + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, _ => -1, }; } } -sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter +sealed class ThresholdTotalAmountConversionRateConfigConverter + : JsonConverter { - public override ReplaceAdjustmentAdjustment? Read( + public override ThresholdTotalAmountConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; + string? conversionRateType; try { - adjustmentType = element.GetProperty("adjustment_type").GetString(); + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); } catch { - adjustmentType = null; + conversionRateType = null; } - switch (adjustmentType) + switch (conversionRateType) { - 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": + case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9307,11 +9701,11 @@ JsonSerializerOptions options return new(element); } - case "amount_discount": + case "tiered": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9329,54 +9723,16 @@ 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 ReplaceAdjustmentAdjustment(element); + return new ThresholdTotalAmountConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, + ThresholdTotalAmountConversionRateConfig value, JsonSerializerOptions options ) { @@ -9384,110 +9740,66330 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackage : JsonModel { /// - /// The id of the price on the plan to replace in the plan. + /// The cadence to bill for this price on. /// - public required string ReplacesPriceID + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); + return this._rawData.GetNotNullClass>("cadence"); } - init { this._rawData.Set("replaces_price_id", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The allocation price to add to the plan. + /// The id of the item the price will be associated with. /// - public NewAllocationPrice? AllocationPrice + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("allocation_price", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The phase to replace this price from. + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public long? PlanPhaseOrder + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("plan_phase_order", value); } } /// - /// New plan price request body params. + /// The pricing model type /// - public ReplacePricePrice? Price + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("price", value); } + init { this._rawData.Set("model_type", value); } } - /// - public override void Validate() + /// + /// The name of the price. + /// + public required string Name { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - _ = this.PlanPhaseOrder; - this.Price?.Validate(); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } } - public ReplacePrice() { } + /// + /// Configuration for tiered_package pricing + /// + public required TieredPackageConfig TieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tiered_package_config"); + } + init { this._rawData.Set("tiered_package_config", value); } + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } -#pragma warning restore CS8618 + /// + /// 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); } + } - public ReplacePrice(IReadOnlyDictionary 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 { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } } -#pragma warning restore CS8618 - /// - public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public TieredPackageConversionRateConfig? ConversionRateConfig { - this.ReplacesPriceID = replacesPriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } -} -class ReplacePriceFromRaw : IFromRawJson -{ - /// - public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplacePrice.FromRawUnchecked(rawData); + /// + /// 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackage(TieredPackage tieredPackage) + : base(tieredPackage) { } +#pragma warning restore CS8618 + + public TieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackage FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageFromRaw : IFromRawJson +{ + /// + public TieredPackage FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredPackageCadenceConverter))] +public enum TieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredPackageCadenceConverter : JsonConverter +{ + public override TieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredPackageCadence.Annual, + "semi_annual" => TieredPackageCadence.SemiAnnual, + "monthly" => TieredPackageCadence.Monthly, + "quarterly" => TieredPackageCadence.Quarterly, + "one_time" => TieredPackageCadence.OneTime, + "custom" => TieredPackageCadence.Custom, + _ => (TieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredPackageCadence.Annual => "annual", + TieredPackageCadence.SemiAnnual => "semi_annual", + TieredPackageCadence.Monthly => "monthly", + TieredPackageCadence.Quarterly => "quarterly", + TieredPackageCadence.OneTime => "one_time", + TieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageLicenseAllocation, + TieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class TieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageLicenseAllocation( + TieredPackageLicenseAllocation tieredPackageLicenseAllocation + ) + : base(tieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageLicenseAllocationFromRaw : IFromRawJson +{ + /// + public TieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_package pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackageConfig : JsonModel +{ + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. The tier bounds are defined + /// based on the total quantity rather than the number of packages, so they must + /// be multiples of the package size. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageConfig(TieredPackageConfig tieredPackageConfig) + : base(tieredPackageConfig) { } +#pragma warning restore CS8618 + + public TieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageConfigFromRaw : IFromRawJson +{ + /// + public TieredPackageConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier with business logic +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackageConfigTier : JsonModel +{ + /// + /// Price per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public TieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageConfigTier(TieredPackageConfigTier tieredPackageConfigTier) + : base(tieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public TieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public TieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredPackageConversionRateConfigConverter))] +public record class TieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageConversionRateConfig(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 TieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 TieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator TieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredPackageConversionRateConfig( + 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 TieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override TieredPackageConversionRateConfig? 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 TieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithMinimum : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_with_minimum pricing + /// + public required TieredWithMinimumConfig TieredWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_with_minimum_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 TieredWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimum(TieredWithMinimum tieredWithMinimum) + : base(tieredWithMinimum) { } +#pragma warning restore CS8618 + + public TieredWithMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumFromRaw : IFromRawJson +{ + /// + public TieredWithMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithMinimumCadenceConverter))] +public enum TieredWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithMinimumCadenceConverter : JsonConverter +{ + public override TieredWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredWithMinimumCadence.Annual, + "semi_annual" => TieredWithMinimumCadence.SemiAnnual, + "monthly" => TieredWithMinimumCadence.Monthly, + "quarterly" => TieredWithMinimumCadence.Quarterly, + "one_time" => TieredWithMinimumCadence.OneTime, + "custom" => TieredWithMinimumCadence.Custom, + _ => (TieredWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredWithMinimumCadence.Annual => "annual", + TieredWithMinimumCadence.SemiAnnual => "semi_annual", + TieredWithMinimumCadence.Monthly => "monthly", + TieredWithMinimumCadence.Quarterly => "quarterly", + TieredWithMinimumCadence.OneTime => "one_time", + TieredWithMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredWithMinimumLicenseAllocation, + TieredWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class TieredWithMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumLicenseAllocation( + TieredWithMinimumLicenseAllocation tieredWithMinimumLicenseAllocation + ) + : base(tieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithMinimumLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumLicenseAllocationFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_with_minimum pricing +/// +[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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// If true, tiers with an accrued amount of 0 will not be included in the rating. + /// + public bool? HideZeroAmountTiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hide_zero_amount_tiers"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hide_zero_amount_tiers", value); + } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prorate", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.HideZeroAmountTiers; + _ = this.Prorate; + } + + public TieredWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) + : base(tieredWithMinimumConfig) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithMinimumConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithMinimumConfigFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithMinimumConfigTier : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.MinimumAmount; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public TieredWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfigTier(TieredWithMinimumConfigTier tieredWithMinimumConfigTier) + : base(tieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithMinimumConversionRateConfigConverter))] +public record class TieredWithMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithMinimumConversionRateConfig(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 TieredWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 TieredWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator TieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredWithMinimumConversionRateConfig( + 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 TieredWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithMinimumConversionRateConfig? 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 TieredWithMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTiered : 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); } + } + + /// + /// Configuration for grouped_tiered pricing + /// + public required GroupedTieredConfig GroupedTieredConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouped_tiered_config"); + } + init { this._rawData.Set("grouped_tiered_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedTieredConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedTiered() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTiered(GroupedTiered groupedTiered) + : base(groupedTiered) { } +#pragma warning restore CS8618 + + public GroupedTiered(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTiered(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTiered FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredFromRaw : IFromRawJson +{ + /// + public GroupedTiered FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTiered.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedTieredCadenceConverter))] +public enum GroupedTieredCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedTieredCadenceConverter : JsonConverter +{ + public override GroupedTieredCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedTieredCadence.Annual, + "semi_annual" => GroupedTieredCadence.SemiAnnual, + "monthly" => GroupedTieredCadence.Monthly, + "quarterly" => GroupedTieredCadence.Quarterly, + "one_time" => GroupedTieredCadence.OneTime, + "custom" => GroupedTieredCadence.Custom, + _ => (GroupedTieredCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedTieredCadence.Annual => "annual", + GroupedTieredCadence.SemiAnnual => "semi_annual", + GroupedTieredCadence.Monthly => "monthly", + GroupedTieredCadence.Quarterly => "quarterly", + GroupedTieredCadence.OneTime => "one_time", + GroupedTieredCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredConfig : JsonModel +{ + /// + /// The billable metric property used to group before tiering + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Apply tiered pricing to each segment generated after grouping with the provided key + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public GroupedTieredConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) + : base(groupedTieredConfig) { } +#pragma warning restore CS8618 + + public GroupedTieredConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredConfigFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTieredConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredConfigTier : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public GroupedTieredConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) + : base(groupedTieredConfigTier) { } +#pragma warning restore CS8618 + + public GroupedTieredConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredConfigTierFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredLicenseAllocation, + GroupedTieredLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedTieredLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedTieredLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredLicenseAllocation( + GroupedTieredLicenseAllocation groupedTieredLicenseAllocation + ) + : base(groupedTieredLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedTieredLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredLicenseAllocationFromRaw : IFromRawJson +{ + /// + public GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedTieredConversionRateConfigConverter))] +public record class GroupedTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredConversionRateConfig(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 GroupedTieredConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedTieredConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedTieredConversionRateConfig( + 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 GroupedTieredConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedTieredConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedTieredConversionRateConfigConverter + : JsonConverter +{ + public override GroupedTieredConversionRateConfig? 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 GroupedTieredConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredPackageWithMinimum : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_package_with_minimum pricing + /// + public required TieredPackageWithMinimumConfig TieredPackageWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_package_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_package_with_minimum_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 TieredPackageWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredPackageWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimum(TieredPackageWithMinimum tieredPackageWithMinimum) + : base(tieredPackageWithMinimum) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredPackageWithMinimumCadenceConverter))] +public enum TieredPackageWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredPackageWithMinimumCadenceConverter + : JsonConverter +{ + public override TieredPackageWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredPackageWithMinimumCadence.Annual, + "semi_annual" => TieredPackageWithMinimumCadence.SemiAnnual, + "monthly" => TieredPackageWithMinimumCadence.Monthly, + "quarterly" => TieredPackageWithMinimumCadence.Quarterly, + "one_time" => TieredPackageWithMinimumCadence.OneTime, + "custom" => TieredPackageWithMinimumCadence.Custom, + _ => (TieredPackageWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredPackageWithMinimumCadence.Annual => "annual", + TieredPackageWithMinimumCadence.SemiAnnual => "semi_annual", + TieredPackageWithMinimumCadence.Monthly => "monthly", + TieredPackageWithMinimumCadence.Quarterly => "quarterly", + TieredPackageWithMinimumCadence.OneTime => "one_time", + TieredPackageWithMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumLicenseAllocation, + TieredPackageWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredPackageWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumLicenseAllocation( + TieredPackageWithMinimumLicenseAllocation tieredPackageWithMinimumLicenseAllocation + ) + : base(tieredPackageWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_package_with_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumConfig, + TieredPackageWithMinimumConfigFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumConfig : JsonModel +{ + public required double PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredPackageWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumConfig( + TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig + ) + : base(tieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumConfigFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumConfigTier, + TieredPackageWithMinimumConfigTierFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumConfigTier : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.MinimumAmount; + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public TieredPackageWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumConfigTier( + TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier + ) + : base(tieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumConfigTierFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredPackageWithMinimumConversionRateConfigConverter))] +public record class TieredPackageWithMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageWithMinimumConversionRateConfig(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 TieredPackageWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 TieredPackageWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator TieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredPackageWithMinimumConversionRateConfig( + 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 TieredPackageWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredPackageWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredPackageWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override TieredPackageWithMinimumConversionRateConfig? 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 TieredPackageWithMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PackageWithAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 package_with_allocation pricing + /// + public required PackageWithAllocationConfig PackageWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "package_with_allocation_config" + ); + } + init { this._rawData.Set("package_with_allocation_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 PackageWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("package_with_allocation") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.PackageWithAllocationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PackageWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocation(PackageWithAllocation packageWithAllocation) + : base(packageWithAllocation) { } +#pragma warning restore CS8618 + + public PackageWithAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationFromRaw : IFromRawJson +{ + /// + public PackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PackageWithAllocationCadenceConverter))] +public enum PackageWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PackageWithAllocationCadenceConverter : JsonConverter +{ + public override PackageWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PackageWithAllocationCadence.Annual, + "semi_annual" => PackageWithAllocationCadence.SemiAnnual, + "monthly" => PackageWithAllocationCadence.Monthly, + "quarterly" => PackageWithAllocationCadence.Quarterly, + "one_time" => PackageWithAllocationCadence.OneTime, + "custom" => PackageWithAllocationCadence.Custom, + _ => (PackageWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PackageWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PackageWithAllocationCadence.Annual => "annual", + PackageWithAllocationCadence.SemiAnnual => "semi_annual", + PackageWithAllocationCadence.Monthly => "monthly", + PackageWithAllocationCadence.Quarterly => "quarterly", + PackageWithAllocationCadence.OneTime => "one_time", + PackageWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PackageWithAllocationLicenseAllocation, + PackageWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class PackageWithAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public PackageWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocationLicenseAllocation( + PackageWithAllocationLicenseAllocation packageWithAllocationLicenseAllocation + ) + : base(packageWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public PackageWithAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public PackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for package_with_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PackageWithAllocationConfig : JsonModel +{ + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + public required string PackageAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_amount"); + } + init { this._rawData.Set("package_amount", value); } + } + + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.PackageAmount; + _ = this.PackageSize; + } + + public PackageWithAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocationConfig(PackageWithAllocationConfig packageWithAllocationConfig) + : base(packageWithAllocationConfig) { } +#pragma warning restore CS8618 + + public PackageWithAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationConfigFromRaw : IFromRawJson +{ + /// + public PackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PackageWithAllocationConversionRateConfigConverter))] +public record class PackageWithAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PackageWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PackageWithAllocationConversionRateConfig(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 PackageWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 PackageWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator PackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PackageWithAllocationConversionRateConfig( + 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 PackageWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PackageWithAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PackageWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override PackageWithAllocationConversionRateConfig? 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 PackageWithAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PackageWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithPercent : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 unit_with_percent pricing + /// + public required UnitWithPercentConfig UnitWithPercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_with_percent_config"); + } + init { this._rawData.Set("unit_with_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 UnitWithPercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_percent") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithPercentConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public UnitWithPercent() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercent(UnitWithPercent unitWithPercent) + : base(unitWithPercent) { } +#pragma warning restore CS8618 + + public UnitWithPercent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercent FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentFromRaw : IFromRawJson +{ + /// + public UnitWithPercent FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitWithPercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(UnitWithPercentCadenceConverter))] +public enum UnitWithPercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class UnitWithPercentCadenceConverter : JsonConverter +{ + public override UnitWithPercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => UnitWithPercentCadence.Annual, + "semi_annual" => UnitWithPercentCadence.SemiAnnual, + "monthly" => UnitWithPercentCadence.Monthly, + "quarterly" => UnitWithPercentCadence.Quarterly, + "one_time" => UnitWithPercentCadence.OneTime, + "custom" => UnitWithPercentCadence.Custom, + _ => (UnitWithPercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithPercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UnitWithPercentCadence.Annual => "annual", + UnitWithPercentCadence.SemiAnnual => "semi_annual", + UnitWithPercentCadence.Monthly => "monthly", + UnitWithPercentCadence.Quarterly => "quarterly", + UnitWithPercentCadence.OneTime => "one_time", + UnitWithPercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnitWithPercentLicenseAllocation, + UnitWithPercentLicenseAllocationFromRaw + >) +)] +public sealed record class UnitWithPercentLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public UnitWithPercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercentLicenseAllocation( + UnitWithPercentLicenseAllocation unitWithPercentLicenseAllocation + ) + : base(unitWithPercentLicenseAllocation) { } +#pragma warning restore CS8618 + + public UnitWithPercentLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercentLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentLicenseAllocationFromRaw : IFromRawJson +{ + /// + public UnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithPercentLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for unit_with_percent pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithPercentConfig : JsonModel +{ + /// + /// What percent, out of 100, of the calculated total to charge + /// + public required string Percent + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent"); + } + init { this._rawData.Set("percent", value); } + } + + /// + /// Rate per unit of usage + /// + 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.Percent; + _ = this.UnitAmount; + } + + public UnitWithPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercentConfig(UnitWithPercentConfig unitWithPercentConfig) + : base(unitWithPercentConfig) { } +#pragma warning restore CS8618 + + public UnitWithPercentConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercentConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentConfigFromRaw : IFromRawJson +{ + /// + public UnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithPercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UnitWithPercentConversionRateConfigConverter))] +public record class UnitWithPercentConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithPercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithPercentConversionRateConfig(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 UnitWithPercentConversionRateConfig" + ); + } + } + + /// + /// 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 UnitWithPercentConversionRateConfig" + ), + }; + } + + public static implicit operator UnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator UnitWithPercentConversionRateConfig( + 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 UnitWithPercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(UnitWithPercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class UnitWithPercentConversionRateConfigConverter + : JsonConverter +{ + public override UnitWithPercentConversionRateConfig? 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 UnitWithPercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithPercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixWithAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for matrix_with_allocation pricing + /// + public required MatrixWithAllocationConfig MatrixWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_allocation_config" + ); + } + init { this._rawData.Set("matrix_with_allocation_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 MatrixWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithAllocationConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MatrixWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithAllocation(MatrixWithAllocation matrixWithAllocation) + : base(matrixWithAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithAllocationFromRaw : IFromRawJson +{ + /// + public MatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixWithAllocationCadenceConverter))] +public enum MatrixWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixWithAllocationCadenceConverter : JsonConverter +{ + public override MatrixWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixWithAllocationCadence.Annual, + "semi_annual" => MatrixWithAllocationCadence.SemiAnnual, + "monthly" => MatrixWithAllocationCadence.Monthly, + "quarterly" => MatrixWithAllocationCadence.Quarterly, + "one_time" => MatrixWithAllocationCadence.OneTime, + "custom" => MatrixWithAllocationCadence.Custom, + _ => (MatrixWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixWithAllocationCadence.Annual => "annual", + MatrixWithAllocationCadence.SemiAnnual => "semi_annual", + MatrixWithAllocationCadence.Monthly => "monthly", + MatrixWithAllocationCadence.Quarterly => "quarterly", + MatrixWithAllocationCadence.OneTime => "one_time", + MatrixWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithAllocationLicenseAllocation, + MatrixWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class MatrixWithAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MatrixWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithAllocationLicenseAllocation( + MatrixWithAllocationLicenseAllocation matrixWithAllocationLicenseAllocation + ) + : base(matrixWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithAllocationConversionRateConfigConverter))] +public record class MatrixWithAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithAllocationConversionRateConfig(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 MatrixWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 MatrixWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator MatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MatrixWithAllocationConversionRateConfig( + 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 MatrixWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MatrixWithAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MatrixWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override MatrixWithAllocationConversionRateConfig? 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 MatrixWithAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithProration : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_with_proration pricing + /// + public required TieredWithProrationConfig 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. + /// + 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 TieredWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + 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(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 + + public TieredWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationFromRaw : IFromRawJson +{ + /// + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithProrationCadenceConverter : JsonConverter +{ + public override TieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + TieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredWithProrationLicenseAllocation, + TieredWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class TieredWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationLicenseAllocation( + TieredWithProrationLicenseAllocation tieredWithProrationLicenseAllocation + ) + : base(tieredWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public TieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfig : 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>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) + : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithProrationConfigFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfigTier : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + 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 TieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier + ) + : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig(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 TieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 TieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredWithProrationConversionRateConfig( + 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 TieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithProrationConversionRateConfig? 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 TieredWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithProration : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 unit_with_proration pricing + /// + public required UnitWithProrationConfig UnitWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "unit_with_proration_config" + ); + } + init { this._rawData.Set("unit_with_proration_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 UnitWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithProrationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public UnitWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProration(UnitWithProration unitWithProration) + : base(unitWithProration) { } +#pragma warning restore CS8618 + + public UnitWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithProrationFromRaw : IFromRawJson +{ + /// + public UnitWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(UnitWithProrationCadenceConverter))] +public enum UnitWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class UnitWithProrationCadenceConverter : JsonConverter +{ + public override UnitWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => UnitWithProrationCadence.Annual, + "semi_annual" => UnitWithProrationCadence.SemiAnnual, + "monthly" => UnitWithProrationCadence.Monthly, + "quarterly" => UnitWithProrationCadence.Quarterly, + "one_time" => UnitWithProrationCadence.OneTime, + "custom" => UnitWithProrationCadence.Custom, + _ => (UnitWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UnitWithProrationCadence.Annual => "annual", + UnitWithProrationCadence.SemiAnnual => "semi_annual", + UnitWithProrationCadence.Monthly => "monthly", + UnitWithProrationCadence.Quarterly => "quarterly", + UnitWithProrationCadence.OneTime => "one_time", + UnitWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnitWithProrationLicenseAllocation, + UnitWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class UnitWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public UnitWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationLicenseAllocation( + UnitWithProrationLicenseAllocation unitWithProrationLicenseAllocation + ) + : base(unitWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public UnitWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithProrationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public UnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for unit_with_proration pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithProrationConfig : JsonModel +{ + /// + /// Rate per unit of usage + /// + 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.UnitAmount; + } + + public UnitWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationConfig(UnitWithProrationConfig unitWithProrationConfig) + : base(unitWithProrationConfig) { } +#pragma warning restore CS8618 + + public UnitWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnitWithProrationConfig(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class UnitWithProrationConfigFromRaw : IFromRawJson +{ + /// + public UnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithProrationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UnitWithProrationConversionRateConfigConverter))] +public record class UnitWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithProrationConversionRateConfig(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 UnitWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 UnitWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator UnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator UnitWithProrationConversionRateConfig( + 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 UnitWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(UnitWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class UnitWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override UnitWithProrationConversionRateConfig? 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 UnitWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedAllocation : 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); } + } + + /// + /// Configuration for grouped_allocation pricing + /// + public required GroupedAllocationConfig GroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_allocation_config" + ); + } + init { this._rawData.Set("grouped_allocation_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocation(GroupedAllocation groupedAllocation) + : base(groupedAllocation) { } +#pragma warning restore CS8618 + + public GroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationFromRaw : IFromRawJson +{ + /// + public GroupedAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedAllocationCadenceConverter))] +public enum GroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedAllocationCadenceConverter : JsonConverter +{ + public override GroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedAllocationCadence.Annual, + "semi_annual" => GroupedAllocationCadence.SemiAnnual, + "monthly" => GroupedAllocationCadence.Monthly, + "quarterly" => GroupedAllocationCadence.Quarterly, + "one_time" => GroupedAllocationCadence.OneTime, + "custom" => GroupedAllocationCadence.Custom, + _ => (GroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedAllocationCadence.Annual => "annual", + GroupedAllocationCadence.SemiAnnual => "semi_annual", + GroupedAllocationCadence.Monthly => "monthly", + GroupedAllocationCadence.Quarterly => "quarterly", + GroupedAllocationCadence.OneTime => "one_time", + GroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_allocation pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedAllocationConfig : JsonModel +{ + /// + /// Usage allocation per group + /// + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + /// + /// How to determine the groups that should each be allocated some quantity + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Unit rate for post-allocation + /// + public required string OverageUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("overage_unit_rate"); + } + init { this._rawData.Set("overage_unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.GroupingKey; + _ = this.OverageUnitRate; + } + + public GroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationConfig(GroupedAllocationConfig groupedAllocationConfig) + : base(groupedAllocationConfig) { } +#pragma warning restore CS8618 + + public GroupedAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationConfigFromRaw : IFromRawJson +{ + /// + public GroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedAllocationLicenseAllocation, + GroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationLicenseAllocation( + GroupedAllocationLicenseAllocation groupedAllocationLicenseAllocation + ) + : base(groupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public GroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedAllocationConversionRateConfigConverter))] +public record class GroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedAllocationConversionRateConfig(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 GroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedAllocationConversionRateConfig( + 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 GroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override GroupedAllocationConversionRateConfig? 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 GroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithProration : JsonModel +{ + /// + /// Configuration for bulk_with_proration pricing + /// + public required BulkWithProrationConfig BulkWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_proration_config" + ); + } + init { this._rawData.Set("bulk_with_proration_config", value); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 BulkWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.BulkWithProrationConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("bulk_with_proration") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public BulkWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProration(BulkWithProration bulkWithProration) + : base(bulkWithProration) { } +#pragma warning restore CS8618 + + public BulkWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationFromRaw : IFromRawJson +{ + /// + public BulkWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithProration.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_proration pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithProrationConfig : JsonModel +{ + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public BulkWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationConfig(BulkWithProrationConfig bulkWithProrationConfig) + : base(bulkWithProrationConfig) { } +#pragma warning restore CS8618 + + public BulkWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BulkWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class BulkWithProrationConfigFromRaw : IFromRawJson +{ + /// + public BulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier with proration +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class BulkWithProrationConfigTier : JsonModel +{ + /// + /// Cost 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 BulkWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationConfigTier(BulkWithProrationConfigTier bulkWithProrationConfigTier) + : base(bulkWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public BulkWithProrationConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BulkWithProrationConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class BulkWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public BulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(BulkWithProrationCadenceConverter))] +public enum BulkWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class BulkWithProrationCadenceConverter : JsonConverter +{ + public override BulkWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => BulkWithProrationCadence.Annual, + "semi_annual" => BulkWithProrationCadence.SemiAnnual, + "monthly" => BulkWithProrationCadence.Monthly, + "quarterly" => BulkWithProrationCadence.Quarterly, + "one_time" => BulkWithProrationCadence.OneTime, + "custom" => BulkWithProrationCadence.Custom, + _ => (BulkWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithProrationCadence.Annual => "annual", + BulkWithProrationCadence.SemiAnnual => "semi_annual", + BulkWithProrationCadence.Monthly => "monthly", + BulkWithProrationCadence.Quarterly => "quarterly", + BulkWithProrationCadence.OneTime => "one_time", + BulkWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + BulkWithProrationLicenseAllocation, + BulkWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class BulkWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public BulkWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationLicenseAllocation( + BulkWithProrationLicenseAllocation bulkWithProrationLicenseAllocation + ) + : base(bulkWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public BulkWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public BulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(BulkWithProrationConversionRateConfigConverter))] +public record class BulkWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public BulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkWithProrationConversionRateConfig(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 BulkWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 BulkWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator BulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator BulkWithProrationConversionRateConfig( + 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 BulkWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(BulkWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class BulkWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override BulkWithProrationConversionRateConfig? 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 BulkWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithProratedMinimum : 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); } + } + + /// + /// Configuration for grouped_with_prorated_minimum pricing + /// + public required GroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_prorated_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_prorated_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithProratedMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithProratedMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_prorated_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithProratedMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimum(GroupedWithProratedMinimum groupedWithProratedMinimum) + : base(groupedWithProratedMinimum) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumFromRaw : IFromRawJson +{ + /// + public GroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithProratedMinimumCadenceConverter))] +public enum GroupedWithProratedMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithProratedMinimumCadenceConverter + : JsonConverter +{ + public override GroupedWithProratedMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedWithProratedMinimumCadence.Annual, + "semi_annual" => GroupedWithProratedMinimumCadence.SemiAnnual, + "monthly" => GroupedWithProratedMinimumCadence.Monthly, + "quarterly" => GroupedWithProratedMinimumCadence.Quarterly, + "one_time" => GroupedWithProratedMinimumCadence.OneTime, + "custom" => GroupedWithProratedMinimumCadence.Custom, + _ => (GroupedWithProratedMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithProratedMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithProratedMinimumCadence.Annual => "annual", + GroupedWithProratedMinimumCadence.SemiAnnual => "semi_annual", + GroupedWithProratedMinimumCadence.Monthly => "monthly", + GroupedWithProratedMinimumCadence.Quarterly => "quarterly", + GroupedWithProratedMinimumCadence.OneTime => "one_time", + GroupedWithProratedMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_prorated_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumConfig, + GroupedWithProratedMinimumConfigFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumConfig : JsonModel +{ + /// + /// How to determine the groups that should each have a minimum + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group + /// + public required string Minimum + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum"); + } + init { this._rawData.Set("minimum", value); } + } + + /// + /// The amount to charge per unit + /// + public required string UnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rate"); + } + init { this._rawData.Set("unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.Minimum; + _ = this.UnitRate; + } + + public GroupedWithProratedMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumConfig( + GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig + ) + : base(groupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumConfigFromRaw : IFromRawJson +{ + /// + public GroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumLicenseAllocation, + GroupedWithProratedMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithProratedMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumLicenseAllocation( + GroupedWithProratedMinimumLicenseAllocation groupedWithProratedMinimumLicenseAllocation + ) + : base(groupedWithProratedMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedWithProratedMinimumConversionRateConfigConverter))] +public record class GroupedWithProratedMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithProratedMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithProratedMinimumConversionRateConfig(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 GroupedWithProratedMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedWithProratedMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedWithProratedMinimumConversionRateConfig( + 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 GroupedWithProratedMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedWithProratedMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedWithProratedMinimumConversionRateConfigConverter + : JsonConverter +{ + public override GroupedWithProratedMinimumConversionRateConfig? 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 GroupedWithProratedMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithProratedMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithMeteredMinimum : 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); } + } + + /// + /// Configuration for grouped_with_metered_minimum pricing + /// + public required GroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_metered_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_metered_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithMeteredMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMeteredMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_metered_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithMeteredMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimum(GroupedWithMeteredMinimum groupedWithMeteredMinimum) + : base(groupedWithMeteredMinimum) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumFromRaw : IFromRawJson +{ + /// + public GroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithMeteredMinimumCadenceConverter))] +public enum GroupedWithMeteredMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithMeteredMinimumCadenceConverter + : JsonConverter +{ + public override GroupedWithMeteredMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedWithMeteredMinimumCadence.Annual, + "semi_annual" => GroupedWithMeteredMinimumCadence.SemiAnnual, + "monthly" => GroupedWithMeteredMinimumCadence.Monthly, + "quarterly" => GroupedWithMeteredMinimumCadence.Quarterly, + "one_time" => GroupedWithMeteredMinimumCadence.OneTime, + "custom" => GroupedWithMeteredMinimumCadence.Custom, + _ => (GroupedWithMeteredMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithMeteredMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithMeteredMinimumCadence.Annual => "annual", + GroupedWithMeteredMinimumCadence.SemiAnnual => "semi_annual", + GroupedWithMeteredMinimumCadence.Monthly => "monthly", + GroupedWithMeteredMinimumCadence.Quarterly => "quarterly", + GroupedWithMeteredMinimumCadence.OneTime => "one_time", + GroupedWithMeteredMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_metered_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumConfig, + GroupedWithMeteredMinimumConfigFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumConfig : JsonModel +{ + /// + /// Used to partition the usage into groups. The minimum amount is applied to + /// each group. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group per unit + /// + public required string MinimumUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_unit_amount"); + } + init { this._rawData.Set("minimum_unit_amount", value); } + } + + /// + /// Used to determine the unit rate + /// + public required string PricingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_key"); + } + init { this._rawData.Set("pricing_key", value); } + } + + /// + /// Scale the unit rates by the scaling factor. + /// + public required IReadOnlyList ScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("scaling_factors"); + } + init + { + this._rawData.Set>( + "scaling_factors", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Used to determine the unit rate scaling factor + /// + public required string ScalingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_key"); + } + init { this._rawData.Set("scaling_key", value); } + } + + /// + /// Apply per unit pricing to each pricing value. The minimum amount is applied + /// any unmatched usage. + /// + public required IReadOnlyList UnitAmounts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("unit_amounts"); + } + init + { + this._rawData.Set>( + "unit_amounts", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.MinimumUnitAmount; + _ = this.PricingKey; + foreach (var item in this.ScalingFactors) + { + item.Validate(); + } + _ = this.ScalingKey; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public GroupedWithMeteredMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumConfig( + GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig + ) + : base(groupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumConfigFromRaw : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a scaling factor +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ScalingFactor : JsonModel +{ + public required string ScalingFactorValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public required string ScalingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_value"); + } + init { this._rawData.Set("scaling_value", value); } + } + + /// + public override void Validate() + { + _ = this.ScalingFactorValue; + _ = this.ScalingValue; + } + + public ScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalingFactor(ScalingFactor scalingFactor) + : base(scalingFactor) { } +#pragma warning restore CS8618 + + public ScalingFactor(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalingFactor(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalingFactorFromRaw : IFromRawJson +{ + /// + public ScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) => + ScalingFactor.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a unit amount +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitAmount : JsonModel +{ + public required string PricingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_value"); + } + init { this._rawData.Set("pricing_value", value); } + } + + /// + /// Per unit amount + /// + public required string UnitAmountValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.PricingValue; + _ = this.UnitAmountValue; + } + + public UnitAmount() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitAmount(UnitAmount unitAmount) + : base(unitAmount) { } +#pragma warning restore CS8618 + + public UnitAmount(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitAmount(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitAmount FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitAmountFromRaw : IFromRawJson +{ + /// + public UnitAmount FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitAmount.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumLicenseAllocation, + GroupedWithMeteredMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithMeteredMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumLicenseAllocation( + GroupedWithMeteredMinimumLicenseAllocation groupedWithMeteredMinimumLicenseAllocation + ) + : base(groupedWithMeteredMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedWithMeteredMinimumConversionRateConfigConverter))] +public record class GroupedWithMeteredMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithMeteredMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithMeteredMinimumConversionRateConfig(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 GroupedWithMeteredMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedWithMeteredMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( + 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 GroupedWithMeteredMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedWithMeteredMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedWithMeteredMinimumConversionRateConfigConverter + : JsonConverter +{ + public override GroupedWithMeteredMinimumConversionRateConfig? 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 GroupedWithMeteredMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithMeteredMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithMinMaxThresholds : 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); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [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); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override GroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + GroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + 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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + ) + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 + + 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(JsonModelConverter< + GroupedWithMinMaxThresholdsLicenseAllocation, + GroupedWithMinMaxThresholdsLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithMinMaxThresholdsLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithMinMaxThresholdsLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsLicenseAllocation( + GroupedWithMinMaxThresholdsLicenseAllocation groupedWithMinMaxThresholdsLicenseAllocation + ) + : base(groupedWithMinMaxThresholdsLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholdsLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMinMaxThresholdsLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMinMaxThresholdsLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMinMaxThresholdsLicenseAllocation.FromRawUnchecked(rawData); +} + +[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) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +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); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixWithDisplayName : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for matrix_with_display_name pricing + /// + public required MatrixWithDisplayNameConfig MatrixWithDisplayNameConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_display_name_config" + ); + } + init { this._rawData.Set("matrix_with_display_name_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 MatrixWithDisplayNameConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithDisplayNameConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_display_name") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MatrixWithDisplayName() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) + : base(matrixWithDisplayName) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayName(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayName(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameFromRaw : IFromRawJson +{ + /// + public MatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayName.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixWithDisplayNameCadenceConverter))] +public enum MatrixWithDisplayNameCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixWithDisplayNameCadenceConverter : JsonConverter +{ + public override MatrixWithDisplayNameCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixWithDisplayNameCadence.Annual, + "semi_annual" => MatrixWithDisplayNameCadence.SemiAnnual, + "monthly" => MatrixWithDisplayNameCadence.Monthly, + "quarterly" => MatrixWithDisplayNameCadence.Quarterly, + "one_time" => MatrixWithDisplayNameCadence.OneTime, + "custom" => MatrixWithDisplayNameCadence.Custom, + _ => (MatrixWithDisplayNameCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithDisplayNameCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixWithDisplayNameCadence.Annual => "annual", + MatrixWithDisplayNameCadence.SemiAnnual => "semi_annual", + MatrixWithDisplayNameCadence.Monthly => "monthly", + MatrixWithDisplayNameCadence.Quarterly => "quarterly", + MatrixWithDisplayNameCadence.OneTime => "one_time", + MatrixWithDisplayNameCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameLicenseAllocation, + MatrixWithDisplayNameLicenseAllocationFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MatrixWithDisplayNameLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameLicenseAllocation( + MatrixWithDisplayNameLicenseAllocation matrixWithDisplayNameLicenseAllocation + ) + : base(matrixWithDisplayNameLicenseAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for matrix_with_display_name pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class MatrixWithDisplayNameConfig : 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 + /// + public required IReadOnlyList UnitAmounts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("unit_amounts"); + } + init + { + this._rawData.Set>( + "unit_amounts", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Dimension; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public MatrixWithDisplayNameConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameConfig(MatrixWithDisplayNameConfig matrixWithDisplayNameConfig) + : base(matrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameConfigFromRaw : IFromRawJson +{ + /// + public MatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a unit amount item +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameConfigUnitAmount, + MatrixWithDisplayNameConfigUnitAmountFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameConfigUnitAmount : JsonModel +{ + /// + /// The dimension value + /// + public required string DimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("dimension_value"); + } + init { this._rawData.Set("dimension_value", value); } + } + + /// + /// Display name for this dimension value + /// + public required string DisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("display_name"); + } + 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.DimensionValue; + _ = this.DisplayName; + _ = this.UnitAmount; + } + + public MatrixWithDisplayNameConfigUnitAmount() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameConfigUnitAmount( + MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount + ) + : base(matrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameConfigUnitAmount(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameConfigUnitAmount(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameConfigUnitAmountFromRaw + : IFromRawJson +{ + /// + public MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithDisplayNameConversionRateConfigConverter))] +public record class MatrixWithDisplayNameConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithDisplayNameConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithDisplayNameConversionRateConfig(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 MatrixWithDisplayNameConversionRateConfig" + ); + } + } + + /// + /// 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 MatrixWithDisplayNameConversionRateConfig" + ), + }; + } + + public static implicit operator MatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MatrixWithDisplayNameConversionRateConfig( + 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 MatrixWithDisplayNameConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MatrixWithDisplayNameConversionRateConfigConverter + : JsonConverter +{ + public override MatrixWithDisplayNameConversionRateConfig? 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 MatrixWithDisplayNameConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithDisplayNameConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredPackage : 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); } + } + + /// + /// Configuration for grouped_tiered_package pricing + /// + public required GroupedTieredPackageConfig GroupedTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_package_config" + ); + } + init { this._rawData.Set("grouped_tiered_package_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredPackageConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) + : base(groupedTieredPackage) { } +#pragma warning restore CS8618 + + public GroupedTieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedTieredPackageCadenceConverter))] +public enum GroupedTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedTieredPackageCadenceConverter : JsonConverter +{ + public override GroupedTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedTieredPackageCadence.Annual, + "semi_annual" => GroupedTieredPackageCadence.SemiAnnual, + "monthly" => GroupedTieredPackageCadence.Monthly, + "quarterly" => GroupedTieredPackageCadence.Quarterly, + "one_time" => GroupedTieredPackageCadence.OneTime, + "custom" => GroupedTieredPackageCadence.Custom, + _ => (GroupedTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedTieredPackageCadence.Annual => "annual", + GroupedTieredPackageCadence.SemiAnnual => "semi_annual", + GroupedTieredPackageCadence.Monthly => "monthly", + GroupedTieredPackageCadence.Quarterly => "quarterly", + GroupedTieredPackageCadence.OneTime => "one_time", + GroupedTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedTieredPackageConfig : JsonModel +{ + /// + /// The event property used to group before tiering + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public GroupedTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageConfig(GroupedTieredPackageConfig groupedTieredPackageConfig) + : base(groupedTieredPackageConfig) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageConfigFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredPackageConfigTier, + GroupedTieredPackageConfigTierFromRaw + >) +)] +public sealed record class GroupedTieredPackageConfigTier : JsonModel +{ + /// + /// Per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public GroupedTieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageConfigTier( + GroupedTieredPackageConfigTier groupedTieredPackageConfigTier + ) + : base(groupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredPackageLicenseAllocation, + GroupedTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedTieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageLicenseAllocation( + GroupedTieredPackageLicenseAllocation groupedTieredPackageLicenseAllocation + ) + : base(groupedTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedTieredPackageConversionRateConfigConverter))] +public record class GroupedTieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredPackageConversionRateConfig(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 GroupedTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedTieredPackageConversionRateConfig( + 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 GroupedTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override GroupedTieredPackageConversionRateConfig? 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 GroupedTieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MaxGroupTieredPackage : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for max_group_tiered_package pricing + /// + public required MaxGroupTieredPackageConfig MaxGroupTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "max_group_tiered_package_config" + ); + } + init { this._rawData.Set("max_group_tiered_package_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 MaxGroupTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MaxGroupTieredPackageConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("max_group_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MaxGroupTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) + : base(maxGroupTieredPackage) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MaxGroupTieredPackageCadenceConverter))] +public enum MaxGroupTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MaxGroupTieredPackageCadenceConverter : JsonConverter +{ + public override MaxGroupTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MaxGroupTieredPackageCadence.Annual, + "semi_annual" => MaxGroupTieredPackageCadence.SemiAnnual, + "monthly" => MaxGroupTieredPackageCadence.Monthly, + "quarterly" => MaxGroupTieredPackageCadence.Quarterly, + "one_time" => MaxGroupTieredPackageCadence.OneTime, + "custom" => MaxGroupTieredPackageCadence.Custom, + _ => (MaxGroupTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MaxGroupTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MaxGroupTieredPackageCadence.Annual => "annual", + MaxGroupTieredPackageCadence.SemiAnnual => "semi_annual", + MaxGroupTieredPackageCadence.Monthly => "monthly", + MaxGroupTieredPackageCadence.Quarterly => "quarterly", + MaxGroupTieredPackageCadence.OneTime => "one_time", + MaxGroupTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MaxGroupTieredPackageLicenseAllocation, + MaxGroupTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class MaxGroupTieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MaxGroupTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageLicenseAllocation( + MaxGroupTieredPackageLicenseAllocation maxGroupTieredPackageLicenseAllocation + ) + : base(maxGroupTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for max_group_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class MaxGroupTieredPackageConfig : JsonModel +{ + /// + /// The event property used to group before tiering the group with the highest value + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing to the largest group after grouping with the provided key. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public MaxGroupTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageConfig(MaxGroupTieredPackageConfig maxGroupTieredPackageConfig) + : base(maxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageConfigFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + MaxGroupTieredPackageConfigTier, + MaxGroupTieredPackageConfigTierFromRaw + >) +)] +public sealed record class MaxGroupTieredPackageConfigTier : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public MaxGroupTieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageConfigTier( + MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier + ) + : base(maxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MaxGroupTieredPackageConversionRateConfigConverter))] +public record class MaxGroupTieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MaxGroupTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MaxGroupTieredPackageConversionRateConfig(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 MaxGroupTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 MaxGroupTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator MaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MaxGroupTieredPackageConversionRateConfig( + 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 MaxGroupTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MaxGroupTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override MaxGroupTieredPackageConversionRateConfig? 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 MaxGroupTieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MaxGroupTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class ScalableMatrixWithUnitPricing : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 scalable_matrix_with_unit_pricing pricing + /// + public required ScalableMatrixWithUnitPricingConfig 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); } + } + + /// + /// 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 ScalableMatrixWithUnitPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithUnitPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ScalableMatrixWithUnitPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricing( + ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing + ) + : base(scalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricing(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricing(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCadenceConverter))] +public enum ScalableMatrixWithUnitPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ScalableMatrixWithUnitPricingCadenceConverter + : JsonConverter +{ + public override ScalableMatrixWithUnitPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ScalableMatrixWithUnitPricingCadence.Annual, + "semi_annual" => ScalableMatrixWithUnitPricingCadence.SemiAnnual, + "monthly" => ScalableMatrixWithUnitPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithUnitPricingCadence.Quarterly, + "one_time" => ScalableMatrixWithUnitPricingCadence.OneTime, + "custom" => ScalableMatrixWithUnitPricingCadence.Custom, + _ => (ScalableMatrixWithUnitPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithUnitPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ScalableMatrixWithUnitPricingCadence.Annual => "annual", + ScalableMatrixWithUnitPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithUnitPricingCadence.Monthly => "monthly", + ScalableMatrixWithUnitPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithUnitPricingCadence.OneTime => "one_time", + ScalableMatrixWithUnitPricingCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithUnitPricingLicenseAllocation, + ScalableMatrixWithUnitPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ScalableMatrixWithUnitPricingLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ScalableMatrixWithUnitPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingLicenseAllocation( + ScalableMatrixWithUnitPricingLicenseAllocation scalableMatrixWithUnitPricingLicenseAllocation + ) + : base(scalableMatrixWithUnitPricingLicenseAllocation) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricingLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricingLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for scalable_matrix_with_unit_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithUnitPricingConfig, + ScalableMatrixWithUnitPricingConfigFromRaw + >) +)] +public sealed record class ScalableMatrixWithUnitPricingConfig : 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 + /// + public required IReadOnlyList MatrixScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "matrix_scaling_factors" + ); + } + init + { + this._rawData.Set>( + "matrix_scaling_factors", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The final unit price to rate against the output of the matrix + /// + public required string UnitPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_price"); + } + init { this._rawData.Set("unit_price", value); } + } + + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init { this._rawData.Set("prorate", value); } + } + + /// + /// Used to determine the unit rate (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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + _ = this.UnitPrice; + _ = this.GroupingKey; + _ = this.Prorate; + _ = this.SecondDimension; + } + + public ScalableMatrixWithUnitPricingConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingConfig( + ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig + ) + : base(scalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricingConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricingConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingConfigFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricingConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixScalingFactor : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public MatrixScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixScalingFactor(MatrixScalingFactor matrixScalingFactor) + : base(matrixScalingFactor) { } +#pragma warning restore CS8618 + + public MatrixScalingFactor(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixScalingFactor(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixScalingFactorFromRaw : IFromRawJson +{ + /// + public MatrixScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixScalingFactor.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ScalableMatrixWithUnitPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithUnitPricingConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithUnitPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithUnitPricingConversionRateConfig(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 ScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ScalableMatrixWithUnitPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + 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 ScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter + : JsonConverter +{ + public override ScalableMatrixWithUnitPricingConversionRateConfig? 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 ScalableMatrixWithUnitPricingConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithUnitPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricing, + ScalableMatrixWithTieredPricingFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricing : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 scalable_matrix_with_tiered_pricing pricing + /// + public required ScalableMatrixWithTieredPricingConfig 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); } + } + + /// + /// 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 ScalableMatrixWithTieredPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithTieredPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ScalableMatrixWithTieredPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricing( + ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing + ) + : base(scalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricing(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricing(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCadenceConverter))] +public enum ScalableMatrixWithTieredPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ScalableMatrixWithTieredPricingCadenceConverter + : JsonConverter +{ + public override ScalableMatrixWithTieredPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ScalableMatrixWithTieredPricingCadence.Annual, + "semi_annual" => ScalableMatrixWithTieredPricingCadence.SemiAnnual, + "monthly" => ScalableMatrixWithTieredPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithTieredPricingCadence.Quarterly, + "one_time" => ScalableMatrixWithTieredPricingCadence.OneTime, + "custom" => ScalableMatrixWithTieredPricingCadence.Custom, + _ => (ScalableMatrixWithTieredPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithTieredPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ScalableMatrixWithTieredPricingCadence.Annual => "annual", + ScalableMatrixWithTieredPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithTieredPricingCadence.Monthly => "monthly", + ScalableMatrixWithTieredPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithTieredPricingCadence.OneTime => "one_time", + ScalableMatrixWithTieredPricingCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingLicenseAllocation, + ScalableMatrixWithTieredPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ScalableMatrixWithTieredPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingLicenseAllocation( + ScalableMatrixWithTieredPricingLicenseAllocation scalableMatrixWithTieredPricingLicenseAllocation + ) + : base(scalableMatrixWithTieredPricingLicenseAllocation) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for scalable_matrix_with_tiered_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfig, + ScalableMatrixWithTieredPricingConfigFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfig : JsonModel +{ + /// + /// Used for the scalable matrix first dimension + /// + 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 + >("matrix_scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.SecondDimension; + } + + public ScalableMatrixWithTieredPricingConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfig( + ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig + ) + : base(scalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor, + ScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfigMatrixScalingFactor : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) + : base(scalableMatrixWithTieredPricingConfigMatrixScalingFactor) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier entry with business logic +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfigTier, + ScalableMatrixWithTieredPricingConfigTierFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfigTier : 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 ScalableMatrixWithTieredPricingConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfigTier( + ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier + ) + : base(scalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigTierFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ScalableMatrixWithTieredPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithTieredPricingConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithTieredPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithTieredPricingConversionRateConfig(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 ScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ScalableMatrixWithTieredPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + 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 ScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter + : JsonConverter +{ + public override ScalableMatrixWithTieredPricingConversionRateConfig? 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 ScalableMatrixWithTieredPricingConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithTieredPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CumulativeGroupedBulk : 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); } + } + + /// + /// Configuration for cumulative_grouped_bulk pricing + /// + public required CumulativeGroupedBulkConfig CumulativeGroupedBulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_bulk_config" + ); + } + init { this._rawData.Set("cumulative_grouped_bulk_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 CumulativeGroupedBulkConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedBulkConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_bulk") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public CumulativeGroupedBulk() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) + : base(cumulativeGroupedBulk) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulk(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulk(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulk.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CumulativeGroupedBulkCadenceConverter))] +public enum CumulativeGroupedBulkCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CumulativeGroupedBulkCadenceConverter : JsonConverter +{ + public override CumulativeGroupedBulkCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => CumulativeGroupedBulkCadence.Annual, + "semi_annual" => CumulativeGroupedBulkCadence.SemiAnnual, + "monthly" => CumulativeGroupedBulkCadence.Monthly, + "quarterly" => CumulativeGroupedBulkCadence.Quarterly, + "one_time" => CumulativeGroupedBulkCadence.OneTime, + "custom" => CumulativeGroupedBulkCadence.Custom, + _ => (CumulativeGroupedBulkCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedBulkCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + CumulativeGroupedBulkCadence.Annual => "annual", + CumulativeGroupedBulkCadence.SemiAnnual => "semi_annual", + CumulativeGroupedBulkCadence.Monthly => "monthly", + CumulativeGroupedBulkCadence.Quarterly => "quarterly", + CumulativeGroupedBulkCadence.OneTime => "one_time", + CumulativeGroupedBulkCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_bulk pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CumulativeGroupedBulkConfig : JsonModel +{ + /// + /// Each tier lower bound must have the same group of values. + /// + public required IReadOnlyList DimensionValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "dimension_values" + ); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required string Group + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group"); + } + init { this._rawData.Set("group", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.DimensionValues) + { + item.Validate(); + } + _ = this.Group; + } + + public CumulativeGroupedBulkConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkConfig(CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig) + : base(cumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulkConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkConfigFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a dimension value entry +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DimensionValue : JsonModel +{ + /// + /// Grouping key value + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public DimensionValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DimensionValue(DimensionValue dimensionValue) + : base(dimensionValue) { } +#pragma warning restore CS8618 + + public DimensionValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DimensionValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DimensionValue FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DimensionValueFromRaw : IFromRawJson +{ + /// + public DimensionValue FromRawUnchecked(IReadOnlyDictionary rawData) => + DimensionValue.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedBulkLicenseAllocation, + CumulativeGroupedBulkLicenseAllocationFromRaw + >) +)] +public sealed record class CumulativeGroupedBulkLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public CumulativeGroupedBulkLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkLicenseAllocation( + CumulativeGroupedBulkLicenseAllocation cumulativeGroupedBulkLicenseAllocation + ) + : base(cumulativeGroupedBulkLicenseAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulkLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(CumulativeGroupedBulkConversionRateConfigConverter))] +public record class CumulativeGroupedBulkConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedBulkConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedBulkConversionRateConfig(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 CumulativeGroupedBulkConversionRateConfig" + ); + } + } + + /// + /// 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 CumulativeGroupedBulkConversionRateConfig" + ), + }; + } + + public static implicit operator CumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator CumulativeGroupedBulkConversionRateConfig( + 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 CumulativeGroupedBulkConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class CumulativeGroupedBulkConversionRateConfigConverter + : JsonConverter +{ + public override CumulativeGroupedBulkConversionRateConfig? 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 CumulativeGroupedBulkConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedBulkConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CumulativeGroupedAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 CumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public CumulativeGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + CumulativeGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationConfig : JsonModel +{ + /// + /// The overall allocation across all groups + /// + public required string CumulativeAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cumulative_allocation"); + } + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", 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.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } + + public CumulativeGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationLicenseAllocation, + CumulativeGroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public CumulativeGroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationLicenseAllocation( + CumulativeGroupedAllocationLicenseAllocation cumulativeGroupedAllocationLicenseAllocation + ) + : base(cumulativeGroupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig(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 CumulativeGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 CumulativeGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + 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 CumulativeGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationConversionRateConfig? 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 CumulativeGroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MinimumComposite : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for minimum_composite pricing + /// + public required MinimumCompositeConfig MinimumCompositeConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "minimum_composite_config" + ); + } + init { this._rawData.Set("minimum_composite_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 MinimumCompositeConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MinimumCompositeConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("minimum_composite") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MinimumComposite() + { + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumComposite(MinimumComposite minimumComposite) + : base(minimumComposite) { } +#pragma warning restore CS8618 + + public MinimumComposite(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumComposite(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumComposite FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MinimumCompositeFromRaw : IFromRawJson +{ + /// + public MinimumComposite FromRawUnchecked(IReadOnlyDictionary rawData) => + MinimumComposite.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MinimumCompositeCadenceConverter))] +public enum MinimumCompositeCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MinimumCompositeCadenceConverter : JsonConverter +{ + public override MinimumCompositeCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MinimumCompositeCadence.Annual, + "semi_annual" => MinimumCompositeCadence.SemiAnnual, + "monthly" => MinimumCompositeCadence.Monthly, + "quarterly" => MinimumCompositeCadence.Quarterly, + "one_time" => MinimumCompositeCadence.OneTime, + "custom" => MinimumCompositeCadence.Custom, + _ => (MinimumCompositeCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MinimumCompositeCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MinimumCompositeCadence.Annual => "annual", + MinimumCompositeCadence.SemiAnnual => "semi_annual", + MinimumCompositeCadence.Monthly => "monthly", + MinimumCompositeCadence.Quarterly => "quarterly", + MinimumCompositeCadence.OneTime => "one_time", + MinimumCompositeCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MinimumCompositeLicenseAllocation, + MinimumCompositeLicenseAllocationFromRaw + >) +)] +public sealed record class MinimumCompositeLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MinimumCompositeLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumCompositeLicenseAllocation( + MinimumCompositeLicenseAllocation minimumCompositeLicenseAllocation + ) + : base(minimumCompositeLicenseAllocation) { } +#pragma warning restore CS8618 + + public MinimumCompositeLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumCompositeLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MinimumCompositeLicenseAllocationFromRaw : IFromRawJson +{ + /// + public MinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MinimumCompositeLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for minimum_composite pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MinimumCompositeConfig : 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 MinimumCompositeConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumCompositeConfig(MinimumCompositeConfig minimumCompositeConfig) + : base(minimumCompositeConfig) { } +#pragma warning restore CS8618 + + public MinimumCompositeConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumCompositeConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public MinimumCompositeConfig(string minimumAmount) + : this() + { + this.MinimumAmount = minimumAmount; + } +} + +class MinimumCompositeConfigFromRaw : IFromRawJson +{ + /// + public MinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MinimumCompositeConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MinimumCompositeConversionRateConfigConverter))] +public record class MinimumCompositeConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MinimumCompositeConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MinimumCompositeConversionRateConfig(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 MinimumCompositeConversionRateConfig" + ); + } + } + + /// + /// 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 MinimumCompositeConversionRateConfig" + ), + }; + } + + public static implicit operator MinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MinimumCompositeConversionRateConfig( + 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 MinimumCompositeConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MinimumCompositeConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MinimumCompositeConversionRateConfigConverter + : JsonConverter +{ + public override MinimumCompositeConversionRateConfig? 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 MinimumCompositeConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MinimumCompositeConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +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>("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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 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 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public Percent() + { + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) + : base(percent) { } +#pragma warning restore CS8618 + + 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 Percent FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PercentFromRaw : IFromRawJson +{ + /// + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PercentCadenceConverter : JsonConverter +{ + public override PercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + PercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PercentLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public PercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentLicenseAllocation(PercentLicenseAllocation percentLicenseAllocation) + : base(percentLicenseAllocation) { } +#pragma warning restore CS8618 + + public PercentLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PercentLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PercentLicenseAllocationFromRaw : IFromRawJson +{ + /// + public PercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PercentLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for percent pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } +#pragma warning restore CS8618 + + 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 PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PercentConfig(double percent) + : this() + { + this.Percent = percent; + } +} + +class PercentConfigFromRaw : IFromRawJson +{ + /// + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(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 PercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator 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(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PercentConversionRateConfigConverter : JsonConverter +{ + public override 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 PercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +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>("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. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 EventOutputConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public EventOutput() + { + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } +#pragma warning restore CS8618 + + public EventOutput(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + EventOutput(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class EventOutputFromRaw : IFromRawJson +{ + /// + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class EventOutputCadenceConverter : JsonConverter +{ + public override EventOutputCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + EventOutputCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for event_output pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel +{ + /// + /// The key in the event data to extract the unit rate from. + /// + public required string UnitRatingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + 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.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; + } + + public EventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } +#pragma warning restore CS8618 + + 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 EventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public EventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +class EventOutputConfigFromRaw : IFromRawJson +{ + /// + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class EventOutputLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public EventOutputLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputLicenseAllocation(EventOutputLicenseAllocation eventOutputLicenseAllocation) + : base(eventOutputLicenseAllocation) { } +#pragma warning restore CS8618 + + public EventOutputLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + EventOutputLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static EventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class EventOutputLicenseAllocationFromRaw : IFromRawJson +{ + /// + public EventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => EventOutputLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(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 + ) + { + this.Value = value; + this._element = element; + } + + public EventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public EventOutputConversionRateConfig(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 EventOutputConversionRateConfig" + ); + } + } + + /// + /// 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 EventOutputConversionRateConfig" + ), + }; + } + + public static implicit operator EventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator EventOutputConversionRateConfig( + 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 EventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class EventOutputConversionRateConfigConverter + : JsonConverter +{ + public override EventOutputConversionRateConfig? 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 EventOutputConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + EventOutputConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// New plan price request body params. +/// +[JsonConverter(typeof(PriceConverter))] +public record class Price : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string ItemID + { + 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, + newPlanMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } + } + + public string Name + { + 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, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } + } + + public string? BillableMetricID + { + 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 bool? BilledInAdvance + { + 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 NewBillingCycleConfiguration? BillingCycleConfiguration + { + 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 double? ConversionRate + { + 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 string? Currency + { + 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 NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + 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 + ); + } + } + + public string? ExternalPriceID + { + 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 double? FixedPriceQuantity + { + 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 string? InvoiceGroupingKey + { + 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 + { + 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 + ); + } + } + + public string? LicenseTypeID + { + get + { + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + + 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, + newPlanMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } + } + + public Price(NewPlanUnitPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceBulkWithFilters value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceTieredWithProration value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceGroupedWithMinMaxThresholds value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanScalableMatrixWithTieredPricingPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceCumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PricePercent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceEventOutput value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(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.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + { + value = this.Value as NewPlanUnitPrice; + 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.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + { + value = this.Value as NewPlanTieredPrice; + 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.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + { + value = this.Value as NewPlanBulkPrice; + 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `PriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters([NotNullWhen(true)] out PriceBulkWithFilters? value) + { + value = this.Value as PriceBulkWithFilters; + 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.TryPickNewPlanPackage(out var value)) { + /// // `value` is of type `NewPlanPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + { + value = this.Value as NewPlanPackagePrice; + 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.TryPickNewPlanMatrix(out var value)) { + /// // `value` is of type `NewPlanMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + { + value = this.Value as NewPlanMatrixPrice; + 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.TryPickNewPlanThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanThresholdTotalAmount( + [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value + ) + { + value = this.Value as NewPlanThresholdTotalAmountPrice; + 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.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` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackageWithMinimum( + [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + ) + { + value = this.Value as NewPlanTieredPackageWithMinimumPrice; + 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.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value + ) + { + value = this.Value as NewPlanPackageWithAllocationPrice; + 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.TryPickNewPlanUnitWithPercent(out var value)) { + /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithPercent( + [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + ) + { + value = this.Value as NewPlanUnitWithPercentPrice; + 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.TryPickNewPlanMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + ) + { + value = this.Value as NewPlanMatrixWithAllocationPrice; + 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.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `PriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration([NotNullWhen(true)] out PriceTieredWithProration? value) + { + value = this.Value as PriceTieredWithProration; + 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.TryPickNewPlanUnitWithProration(out var value)) { + /// // `value` is of type `NewPlanUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithProration( + [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value + ) + { + 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 . + /// + /// 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 + ) + { + 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 . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// 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. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + ) + { + 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 . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + ) + { + 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 . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `PriceGroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out PriceGroupedWithMinMaxThresholds? value + ) + { + value = this.Value as PriceGroupedWithMinMaxThresholds; + 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.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; + } + + /// + /// 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; + } + + /// + /// 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 + ) + { + 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 . + /// + /// 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; + } + + /// + /// 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; + } + + /// + /// 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 `PriceCumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out PriceCumulativeGroupedAllocation? value + ) + { + value = this.Value as PriceCumulativeGroupedAllocation; + 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 `PricePercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out PricePercent? value) + { + value = this.Value as PricePercent; + 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 `PriceEventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) + { + value = this.Value as PriceEventOutput; + 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) => {...}, + /// (PriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (PriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (PriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (PricePercent value) => {...}, + /// (PriceEventOutput 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 + ) + { + switch (this.Value) + { + case NewPlanUnitPrice value: + newPlanUnit(value); + break; + case NewPlanTieredPrice value: + newPlanTiered(value); + break; + case NewPlanBulkPrice value: + newPlanBulk(value); + break; + case PriceBulkWithFilters 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 PriceTieredWithProration 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 PriceGroupedWithMinMaxThresholds 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 PriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewPlanMinimumCompositePrice value: + newPlanMinimumComposite(value); + break; + case PricePercent value: + percent(value); + break; + case PriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException("Data did not match any variant of Price"); + } + } + + /// + /// 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) => {...}, + /// (PriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (PriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (PriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (PricePercent value) => {...}, + /// (PriceEventOutput 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 + ) + { + return this.Value switch + { + NewPlanUnitPrice value => newPlanUnit(value), + NewPlanTieredPrice value => newPlanTiered(value), + NewPlanBulkPrice value => newPlanBulk(value), + PriceBulkWithFilters 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), + PriceTieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + PriceGroupedWithMinMaxThresholds 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), + PriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + PricePercent value => percent(value), + PriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), + }; + } + + public static implicit operator Price(NewPlanUnitPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPrice value) => new(value); + + public static implicit operator Price(NewPlanBulkPrice value) => new(value); + + public static implicit operator Price(PriceBulkWithFilters value) => new(value); + + public static implicit operator Price(NewPlanPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); + + public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); + + public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); + + public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); + + public static implicit operator Price(NewPlanMatrixWithAllocationPrice value) => new(value); + + public static implicit operator Price(PriceTieredWithProration value) => new(value); + + public static implicit operator Price(NewPlanUnitWithProrationPrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedAllocationPrice value) => new(value); + + public static implicit operator Price(NewPlanBulkWithProrationPrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedWithProratedMinimumPrice value) => + new(value); + + public static implicit operator Price(NewPlanGroupedWithMeteredMinimumPrice value) => + new(value); + + public static implicit operator Price(PriceGroupedWithMinMaxThresholds value) => new(value); + + public static implicit operator Price(NewPlanMatrixWithDisplayNamePrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedTieredPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanMaxGroupTieredPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanScalableMatrixWithUnitPricingPrice value) => + new(value); + + public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPrice value) => + new(value); + + public static implicit operator Price(NewPlanCumulativeGroupedBulkPrice value) => new(value); + + public static implicit operator Price(PriceCumulativeGroupedAllocation value) => new(value); + + public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); + + public static implicit operator Price(PricePercent 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 + /// (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 Price"); + } + 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() + ); + } + + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + PriceBulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + PriceTieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + PriceGroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + PriceCumulativeGroupedAllocation _ => 27, + NewPlanMinimumCompositePrice _ => 28, + PricePercent _ => 29, + PriceEventOutput _ => 30, + _ => -1, + }; + } +} + +sealed class PriceConverter : JsonConverter +{ + public override Price? 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_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 Price(element); + } + } + } + + public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value?.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PriceBulkWithFilters : JsonModel +{ + /// + /// Configuration for bulk_with_filters pricing + /// + public required PriceBulkWithFiltersBulkWithFiltersConfig 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>( + "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 PriceBulkWithFiltersConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceBulkWithFilters(PriceBulkWithFilters priceBulkWithFilters) + : base(priceBulkWithFilters) { } +#pragma warning restore CS8618 + + public PriceBulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public PriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceBulkWithFiltersBulkWithFiltersConfig, + PriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class PriceBulkWithFiltersBulkWithFiltersConfig : 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>( + "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>( + "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 PriceBulkWithFiltersBulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceBulkWithFiltersBulkWithFiltersConfig( + PriceBulkWithFiltersBulkWithFiltersConfig priceBulkWithFiltersBulkWithFiltersConfig + ) + : base(priceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public PriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceBulkWithFiltersBulkWithFiltersConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public PriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceBulkWithFiltersBulkWithFiltersConfigFilter, + PriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class PriceBulkWithFiltersBulkWithFiltersConfigFilter : 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 PriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceBulkWithFiltersBulkWithFiltersConfigFilter( + PriceBulkWithFiltersBulkWithFiltersConfigFilter priceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(priceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 + + public PriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceBulkWithFiltersBulkWithFiltersConfigFilter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public PriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceBulkWithFiltersBulkWithFiltersConfigTier, + PriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class PriceBulkWithFiltersBulkWithFiltersConfigTier : 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 PriceBulkWithFiltersBulkWithFiltersConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceBulkWithFiltersBulkWithFiltersConfigTier( + PriceBulkWithFiltersBulkWithFiltersConfigTier priceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(priceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 + + public PriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceBulkWithFiltersBulkWithFiltersConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class PriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public PriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceBulkWithFiltersCadenceConverter))] +public enum PriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceBulkWithFiltersCadenceConverter : JsonConverter +{ + public override PriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceBulkWithFiltersCadence.Annual, + "semi_annual" => PriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => PriceBulkWithFiltersCadence.Monthly, + "quarterly" => PriceBulkWithFiltersCadence.Quarterly, + "one_time" => PriceBulkWithFiltersCadence.OneTime, + "custom" => PriceBulkWithFiltersCadence.Custom, + _ => (PriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceBulkWithFiltersCadence.Annual => "annual", + PriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", + PriceBulkWithFiltersCadence.Monthly => "monthly", + PriceBulkWithFiltersCadence.Quarterly => "quarterly", + PriceBulkWithFiltersCadence.OneTime => "one_time", + PriceBulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(PriceBulkWithFiltersConversionRateConfigConverter))] +public record class PriceBulkWithFiltersConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceBulkWithFiltersConversionRateConfig(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 PriceBulkWithFiltersConversionRateConfig" + ); + } + } + + /// + /// 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 PriceBulkWithFiltersConversionRateConfig" + ), + }; + } + + public static implicit operator PriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceBulkWithFiltersConversionRateConfig( + 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 PriceBulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override PriceBulkWithFiltersConversionRateConfig? 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 PriceBulkWithFiltersConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceBulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PriceTieredWithProration : 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); } + } + + /// + /// 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 tiered_with_proration pricing + /// + public required PriceTieredWithProrationTieredWithProrationConfig 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. + /// + 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 PriceTieredWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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("tiered_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithProrationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceTieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceTieredWithProration(PriceTieredWithProration priceTieredWithProration) + : base(priceTieredWithProration) { } +#pragma warning restore CS8618 + + public PriceTieredWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceTieredWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceTieredWithProrationFromRaw : IFromRawJson +{ + /// + public PriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceTieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceTieredWithProrationCadenceConverter))] +public enum PriceTieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceTieredWithProrationCadenceConverter + : JsonConverter +{ + public override PriceTieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceTieredWithProrationCadence.Annual, + "semi_annual" => PriceTieredWithProrationCadence.SemiAnnual, + "monthly" => PriceTieredWithProrationCadence.Monthly, + "quarterly" => PriceTieredWithProrationCadence.Quarterly, + "one_time" => PriceTieredWithProrationCadence.OneTime, + "custom" => PriceTieredWithProrationCadence.Custom, + _ => (PriceTieredWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceTieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceTieredWithProrationCadence.Annual => "annual", + PriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + PriceTieredWithProrationCadence.Monthly => "monthly", + PriceTieredWithProrationCadence.Quarterly => "quarterly", + PriceTieredWithProrationCadence.OneTime => "one_time", + PriceTieredWithProrationCadence.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< + PriceTieredWithProrationTieredWithProrationConfig, + PriceTieredWithProrationTieredWithProrationConfigFromRaw + >) +)] +public sealed record class PriceTieredWithProrationTieredWithProrationConfig : 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 PriceTieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceTieredWithProrationTieredWithProrationConfig( + PriceTieredWithProrationTieredWithProrationConfig priceTieredWithProrationTieredWithProrationConfig + ) + : base(priceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public PriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceTieredWithProrationTieredWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class PriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public PriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceTieredWithProrationTieredWithProrationConfigTier, + PriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class PriceTieredWithProrationTieredWithProrationConfigTier : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + 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 PriceTieredWithProrationTieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceTieredWithProrationTieredWithProrationConfigTier( + PriceTieredWithProrationTieredWithProrationConfigTier priceTieredWithProrationTieredWithProrationConfigTier + ) + : base(priceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public PriceTieredWithProrationTieredWithProrationConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceTieredWithProrationTieredWithProrationConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public PriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceTieredWithProrationConversionRateConfigConverter))] +public record class PriceTieredWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceTieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceTieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceTieredWithProrationConversionRateConfig(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 PriceTieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 PriceTieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator PriceTieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceTieredWithProrationConversionRateConfig( + 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 PriceTieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceTieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceTieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override PriceTieredWithProrationConversionRateConfig? 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 PriceTieredWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceTieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceGroupedWithMinMaxThresholds, + PriceGroupedWithMinMaxThresholdsFromRaw + >) +)] +public sealed record class PriceGroupedWithMinMaxThresholds : 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); } + } + + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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. + /// + 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 PriceGroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceGroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceGroupedWithMinMaxThresholds( + PriceGroupedWithMinMaxThresholds priceGroupedWithMinMaxThresholds + ) + : base(priceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 + + public PriceGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceGroupedWithMinMaxThresholdsFromRaw : IFromRawJson +{ + /// + public PriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum PriceGroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override PriceGroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => PriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => PriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => PriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => PriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (PriceGroupedWithMinMaxThresholdsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceGroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + PriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + PriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + PriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + PriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_min_max_thresholds pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + >) +)] +public sealed record class PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) + : base(priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 + + public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson +{ + /// + public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class PriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceGroupedWithMinMaxThresholdsConversionRateConfig(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 PriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + } + + /// + /// 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 PriceGroupedWithMinMaxThresholdsConversionRateConfig" + ), + }; + } + + public static implicit operator PriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceGroupedWithMinMaxThresholdsConversionRateConfig( + 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 PriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceGroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter +{ + public override PriceGroupedWithMinMaxThresholdsConversionRateConfig? 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 PriceGroupedWithMinMaxThresholdsConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceGroupedWithMinMaxThresholdsConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceCumulativeGroupedAllocation, + PriceCumulativeGroupedAllocationFromRaw + >) +)] +public sealed record class PriceCumulativeGroupedAllocation : 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); } + } + + /// + /// Configuration for cumulative_grouped_allocation pricing + /// + public required PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); + } + init { this._rawData.Set("cumulative_grouped_allocation_config", 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 PriceCumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceCumulativeGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceCumulativeGroupedAllocation( + PriceCumulativeGroupedAllocation priceCumulativeGroupedAllocation + ) + : base(priceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 + + public PriceCumulativeGroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceCumulativeGroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceCumulativeGroupedAllocationFromRaw : IFromRawJson +{ + /// + public PriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceCumulativeGroupedAllocationCadenceConverter))] +public enum PriceCumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override PriceCumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => PriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => PriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => PriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => PriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => PriceCumulativeGroupedAllocationCadence.Custom, + _ => (PriceCumulativeGroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceCumulativeGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceCumulativeGroupedAllocationCadence.Annual => "annual", + PriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + PriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + PriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + PriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + PriceCumulativeGroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel +{ + /// + /// The overall allocation across all groups + /// + public required string CumulativeAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cumulative_allocation"); + } + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", 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.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } + + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) + : base(priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 + + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson +{ + /// + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class PriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceCumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceCumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceCumulativeGroupedAllocationConversionRateConfig(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 PriceCumulativeGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 PriceCumulativeGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator PriceCumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceCumulativeGroupedAllocationConversionRateConfig( + 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 PriceCumulativeGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override PriceCumulativeGroupedAllocationConversionRateConfig? 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 PriceCumulativeGroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceCumulativeGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PricePercent : 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); } + } + + /// + /// 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 PricePercentPercentConfig 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 PricePercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PricePercent() + { + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePercent(PricePercent pricePercent) + : base(pricePercent) { } +#pragma warning restore CS8618 + + public PricePercent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PricePercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PricePercent FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PricePercentFromRaw : IFromRawJson +{ + /// + public PricePercent FromRawUnchecked(IReadOnlyDictionary rawData) => + PricePercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PricePercentCadenceConverter))] +public enum PricePercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PricePercentCadenceConverter : JsonConverter +{ + public override PricePercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PricePercentCadence.Annual, + "semi_annual" => PricePercentCadence.SemiAnnual, + "monthly" => PricePercentCadence.Monthly, + "quarterly" => PricePercentCadence.Quarterly, + "one_time" => PricePercentCadence.OneTime, + "custom" => PricePercentCadence.Custom, + _ => (PricePercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PricePercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PricePercentCadence.Annual => "annual", + PricePercentCadence.SemiAnnual => "semi_annual", + PricePercentCadence.Monthly => "monthly", + PricePercentCadence.Quarterly => "quarterly", + PricePercentCadence.OneTime => "one_time", + PricePercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for percent pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PricePercentPercentConfig : 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 PricePercentPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePercentPercentConfig(PricePercentPercentConfig pricePercentPercentConfig) + : base(pricePercentPercentConfig) { } +#pragma warning restore CS8618 + + public PricePercentPercentConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PricePercentPercentConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PricePercentPercentConfig(double percent) + : this() + { + this.Percent = percent; + } +} + +class PricePercentPercentConfigFromRaw : IFromRawJson +{ + /// + public PricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePercentPercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PricePercentConversionRateConfigConverter))] +public record class PricePercentConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PricePercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PricePercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PricePercentConversionRateConfig(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 PricePercentConversionRateConfig" + ); + } + } + + /// + /// 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 PricePercentConversionRateConfig" + ), + }; + } + + public static implicit operator PricePercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PricePercentConversionRateConfig( + 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 PricePercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PricePercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PricePercentConversionRateConfigConverter + : JsonConverter +{ + public override PricePercentConversionRateConfig? 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 PricePercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PricePercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PriceEventOutput : 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); } + } + + /// + /// Configuration for event_output pricing + /// + public required PriceEventOutputEventOutputConfig 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. + /// + 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 PriceEventOutputConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceEventOutput() + { + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEventOutput(PriceEventOutput priceEventOutput) + : base(priceEventOutput) { } +#pragma warning restore CS8618 + + public PriceEventOutput(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEventOutput(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEventOutputFromRaw : IFromRawJson +{ + /// + public PriceEventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + PriceEventOutput.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceEventOutputCadenceConverter))] +public enum PriceEventOutputCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceEventOutputCadenceConverter : JsonConverter +{ + public override PriceEventOutputCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceEventOutputCadence.Annual, + "semi_annual" => PriceEventOutputCadence.SemiAnnual, + "monthly" => PriceEventOutputCadence.Monthly, + "quarterly" => PriceEventOutputCadence.Quarterly, + "one_time" => PriceEventOutputCadence.OneTime, + "custom" => PriceEventOutputCadence.Custom, + _ => (PriceEventOutputCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceEventOutputCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceEventOutputCadence.Annual => "annual", + PriceEventOutputCadence.SemiAnnual => "semi_annual", + PriceEventOutputCadence.Monthly => "monthly", + PriceEventOutputCadence.Quarterly => "quarterly", + PriceEventOutputCadence.OneTime => "one_time", + PriceEventOutputCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for event_output pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceEventOutputEventOutputConfig, + PriceEventOutputEventOutputConfigFromRaw + >) +)] +public sealed record class PriceEventOutputEventOutputConfig : JsonModel +{ + /// + /// The key in the event data to extract the unit rate from. + /// + public required string UnitRatingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + 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.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; + } + + public PriceEventOutputEventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEventOutputEventOutputConfig( + PriceEventOutputEventOutputConfig priceEventOutputEventOutputConfig + ) + : base(priceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 + + public PriceEventOutputEventOutputConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEventOutputEventOutputConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PriceEventOutputEventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +class PriceEventOutputEventOutputConfigFromRaw : IFromRawJson +{ + /// + public PriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceEventOutputEventOutputConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceEventOutputConversionRateConfigConverter))] +public record class PriceEventOutputConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEventOutputConversionRateConfig(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 PriceEventOutputConversionRateConfig" + ); + } + } + + /// + /// 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 PriceEventOutputConversionRateConfig" + ), + }; + } + + public static implicit operator PriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceEventOutputConversionRateConfig( + 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 PriceEventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceEventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceEventOutputConversionRateConfigConverter + : JsonConverter +{ + public override PriceEventOutputConversionRateConfig? 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 PriceEventOutputConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceEventOutputConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel +{ + /// + /// The id of the adjustment to remove from on the plan. + /// + public required string AdjustmentID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("adjustment_id"); + } + init { this._rawData.Set("adjustment_id", value); } + } + + /// + /// The phase to remove 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.AdjustmentID; + _ = this.PlanPhaseOrder; + } + + public RemoveAdjustment() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } +#pragma warning restore CS8618 + + 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 RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() + { + this.AdjustmentID = adjustmentID; + } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("plan_phase_order"); + } + init { this._rawData.Set("plan_phase_order", value); } + } + + /// + public override void Validate() + { + _ = this.PriceID; + _ = this.PlanPhaseOrder; + } + + public RemovePrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } +#pragma warning restore CS8618 + + 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 + { + 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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } +#pragma warning restore CS8618 + + 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 + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + 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 + ); + } + } + + public bool? IsInvoiceLevel + { + get + { + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel + ); + } + } + + 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) + { + this.Value = value; + this._element = element; + } + + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + { + this.Value = value; + this._element = 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 . + /// + /// 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) + { + 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; + } + + /// + /// 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; + } + + /// + /// 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 newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum + ) + { + 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" + ); + } + } + + /// + /// 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 + ) + { + 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" + ), + }; + } + + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount 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 + /// (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 ReplaceAdjustmentAdjustment" + ); + } + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); + } + + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } +} + +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter +{ + public override ReplaceAdjustmentAdjustment? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + 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 + } + + return new(element); + } + default: + { + return new ReplaceAdjustmentAdjustment(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplaceAdjustmentAdjustment value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_price_id"); + } + init { this._rawData.Set("replaces_price_id", value); } + } + + /// + /// 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 license allocation price to add to the plan. + /// + public ReplacePriceLicenseAllocationPrice? LicenseAllocationPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_allocation_price" + ); + } + init { this._rawData.Set("license_allocation_price", value); } + } + + /// + /// The phase to replace this price from. + /// + public long? PlanPhaseOrder + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("plan_phase_order"); + } + 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.ReplacesPriceID; + this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); + _ = this.PlanPhaseOrder; + this.Price?.Validate(); + } + + public ReplacePrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } +#pragma warning restore CS8618 + + public ReplacePrice(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePrice(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePrice(string replacesPriceID) + : this() + { + this.ReplacesPriceID = replacesPriceID; + } +} + +class ReplacePriceFromRaw : IFromRawJson +{ + /// + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); +} + +/// +/// The license allocation price to add to the plan. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceConverter))] +public record class ReplacePriceLicenseAllocationPrice : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string ItemID + { + get + { + return Match( + unit: (x) => x.ItemID, + tiered: (x) => x.ItemID, + bulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + package: (x) => x.ItemID, + matrix: (x) => x.ItemID, + thresholdTotalAmount: (x) => x.ItemID, + tieredPackage: (x) => x.ItemID, + tieredWithMinimum: (x) => x.ItemID, + groupedTiered: (x) => x.ItemID, + tieredPackageWithMinimum: (x) => x.ItemID, + packageWithAllocation: (x) => x.ItemID, + unitWithPercent: (x) => x.ItemID, + matrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + unitWithProration: (x) => x.ItemID, + groupedAllocation: (x) => x.ItemID, + bulkWithProration: (x) => x.ItemID, + groupedWithProratedMinimum: (x) => x.ItemID, + groupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + matrixWithDisplayName: (x) => x.ItemID, + groupedTieredPackage: (x) => x.ItemID, + maxGroupTieredPackage: (x) => x.ItemID, + scalableMatrixWithUnitPricing: (x) => x.ItemID, + scalableMatrixWithTieredPricing: (x) => x.ItemID, + cumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + minimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } + } + + public JsonElement ModelType + { + get + { + return Match( + unit: (x) => x.ModelType, + tiered: (x) => x.ModelType, + bulk: (x) => x.ModelType, + bulkWithFilters: (x) => x.ModelType, + package: (x) => x.ModelType, + matrix: (x) => x.ModelType, + thresholdTotalAmount: (x) => x.ModelType, + tieredPackage: (x) => x.ModelType, + tieredWithMinimum: (x) => x.ModelType, + groupedTiered: (x) => x.ModelType, + tieredPackageWithMinimum: (x) => x.ModelType, + packageWithAllocation: (x) => x.ModelType, + unitWithPercent: (x) => x.ModelType, + matrixWithAllocation: (x) => x.ModelType, + tieredWithProration: (x) => x.ModelType, + unitWithProration: (x) => x.ModelType, + groupedAllocation: (x) => x.ModelType, + bulkWithProration: (x) => x.ModelType, + groupedWithProratedMinimum: (x) => x.ModelType, + groupedWithMeteredMinimum: (x) => x.ModelType, + groupedWithMinMaxThresholds: (x) => x.ModelType, + matrixWithDisplayName: (x) => x.ModelType, + groupedTieredPackage: (x) => x.ModelType, + maxGroupTieredPackage: (x) => x.ModelType, + scalableMatrixWithUnitPricing: (x) => x.ModelType, + scalableMatrixWithTieredPricing: (x) => x.ModelType, + cumulativeGroupedBulk: (x) => x.ModelType, + cumulativeGroupedAllocation: (x) => x.ModelType, + minimumComposite: (x) => x.ModelType, + percent: (x) => x.ModelType, + eventOutput: (x) => x.ModelType + ); + } + } + + public string Name + { + get + { + return Match( + unit: (x) => x.Name, + tiered: (x) => x.Name, + bulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + package: (x) => x.Name, + matrix: (x) => x.Name, + thresholdTotalAmount: (x) => x.Name, + tieredPackage: (x) => x.Name, + tieredWithMinimum: (x) => x.Name, + groupedTiered: (x) => x.Name, + tieredPackageWithMinimum: (x) => x.Name, + packageWithAllocation: (x) => x.Name, + unitWithPercent: (x) => x.Name, + matrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + unitWithProration: (x) => x.Name, + groupedAllocation: (x) => x.Name, + bulkWithProration: (x) => x.Name, + groupedWithProratedMinimum: (x) => x.Name, + groupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + matrixWithDisplayName: (x) => x.Name, + groupedTieredPackage: (x) => x.Name, + maxGroupTieredPackage: (x) => x.Name, + scalableMatrixWithUnitPricing: (x) => x.Name, + scalableMatrixWithTieredPricing: (x) => x.Name, + cumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + minimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } + } + + public string? BillableMetricID + { + get + { + return Match( + unit: (x) => x.BillableMetricID, + tiered: (x) => x.BillableMetricID, + bulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + package: (x) => x.BillableMetricID, + matrix: (x) => x.BillableMetricID, + thresholdTotalAmount: (x) => x.BillableMetricID, + tieredPackage: (x) => x.BillableMetricID, + tieredWithMinimum: (x) => x.BillableMetricID, + groupedTiered: (x) => x.BillableMetricID, + tieredPackageWithMinimum: (x) => x.BillableMetricID, + packageWithAllocation: (x) => x.BillableMetricID, + unitWithPercent: (x) => x.BillableMetricID, + matrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + unitWithProration: (x) => x.BillableMetricID, + groupedAllocation: (x) => x.BillableMetricID, + bulkWithProration: (x) => x.BillableMetricID, + groupedWithProratedMinimum: (x) => x.BillableMetricID, + groupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + matrixWithDisplayName: (x) => x.BillableMetricID, + groupedTieredPackage: (x) => x.BillableMetricID, + maxGroupTieredPackage: (x) => x.BillableMetricID, + scalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + scalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + cumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + minimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } + } + + public bool? BilledInAdvance + { + get + { + return Match( + unit: (x) => x.BilledInAdvance, + tiered: (x) => x.BilledInAdvance, + bulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + package: (x) => x.BilledInAdvance, + matrix: (x) => x.BilledInAdvance, + thresholdTotalAmount: (x) => x.BilledInAdvance, + tieredPackage: (x) => x.BilledInAdvance, + tieredWithMinimum: (x) => x.BilledInAdvance, + groupedTiered: (x) => x.BilledInAdvance, + tieredPackageWithMinimum: (x) => x.BilledInAdvance, + packageWithAllocation: (x) => x.BilledInAdvance, + unitWithPercent: (x) => x.BilledInAdvance, + matrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + unitWithProration: (x) => x.BilledInAdvance, + groupedAllocation: (x) => x.BilledInAdvance, + bulkWithProration: (x) => x.BilledInAdvance, + groupedWithProratedMinimum: (x) => x.BilledInAdvance, + groupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + matrixWithDisplayName: (x) => x.BilledInAdvance, + groupedTieredPackage: (x) => x.BilledInAdvance, + maxGroupTieredPackage: (x) => x.BilledInAdvance, + scalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + scalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + cumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + minimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } + } + + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + return Match( + unit: (x) => x.BillingCycleConfiguration, + tiered: (x) => x.BillingCycleConfiguration, + bulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + package: (x) => x.BillingCycleConfiguration, + matrix: (x) => x.BillingCycleConfiguration, + thresholdTotalAmount: (x) => x.BillingCycleConfiguration, + tieredPackage: (x) => x.BillingCycleConfiguration, + tieredWithMinimum: (x) => x.BillingCycleConfiguration, + groupedTiered: (x) => x.BillingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + packageWithAllocation: (x) => x.BillingCycleConfiguration, + unitWithPercent: (x) => x.BillingCycleConfiguration, + matrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + unitWithProration: (x) => x.BillingCycleConfiguration, + groupedAllocation: (x) => x.BillingCycleConfiguration, + bulkWithProration: (x) => x.BillingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + matrixWithDisplayName: (x) => x.BillingCycleConfiguration, + groupedTieredPackage: (x) => x.BillingCycleConfiguration, + maxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + minimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } + } + + public double? ConversionRate + { + get + { + return Match( + unit: (x) => x.ConversionRate, + tiered: (x) => x.ConversionRate, + bulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + package: (x) => x.ConversionRate, + matrix: (x) => x.ConversionRate, + thresholdTotalAmount: (x) => x.ConversionRate, + tieredPackage: (x) => x.ConversionRate, + tieredWithMinimum: (x) => x.ConversionRate, + groupedTiered: (x) => x.ConversionRate, + tieredPackageWithMinimum: (x) => x.ConversionRate, + packageWithAllocation: (x) => x.ConversionRate, + unitWithPercent: (x) => x.ConversionRate, + matrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + unitWithProration: (x) => x.ConversionRate, + groupedAllocation: (x) => x.ConversionRate, + bulkWithProration: (x) => x.ConversionRate, + groupedWithProratedMinimum: (x) => x.ConversionRate, + groupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + matrixWithDisplayName: (x) => x.ConversionRate, + groupedTieredPackage: (x) => x.ConversionRate, + maxGroupTieredPackage: (x) => x.ConversionRate, + scalableMatrixWithUnitPricing: (x) => x.ConversionRate, + scalableMatrixWithTieredPricing: (x) => x.ConversionRate, + cumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + minimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } + } + + public string? Currency + { + get + { + return Match( + unit: (x) => x.Currency, + tiered: (x) => x.Currency, + bulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + package: (x) => x.Currency, + matrix: (x) => x.Currency, + thresholdTotalAmount: (x) => x.Currency, + tieredPackage: (x) => x.Currency, + tieredWithMinimum: (x) => x.Currency, + groupedTiered: (x) => x.Currency, + tieredPackageWithMinimum: (x) => x.Currency, + packageWithAllocation: (x) => x.Currency, + unitWithPercent: (x) => x.Currency, + matrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + unitWithProration: (x) => x.Currency, + groupedAllocation: (x) => x.Currency, + bulkWithProration: (x) => x.Currency, + groupedWithProratedMinimum: (x) => x.Currency, + groupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + matrixWithDisplayName: (x) => x.Currency, + groupedTieredPackage: (x) => x.Currency, + maxGroupTieredPackage: (x) => x.Currency, + scalableMatrixWithUnitPricing: (x) => x.Currency, + scalableMatrixWithTieredPricing: (x) => x.Currency, + cumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + minimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } + } + + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + return Match( + unit: (x) => x.DimensionalPriceConfiguration, + tiered: (x) => x.DimensionalPriceConfiguration, + bulk: (x) => x.DimensionalPriceConfiguration, + bulkWithFilters: (x) => x.DimensionalPriceConfiguration, + package: (x) => x.DimensionalPriceConfiguration, + matrix: (x) => x.DimensionalPriceConfiguration, + thresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + tieredPackage: (x) => x.DimensionalPriceConfiguration, + tieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + groupedTiered: (x) => x.DimensionalPriceConfiguration, + tieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + packageWithAllocation: (x) => x.DimensionalPriceConfiguration, + unitWithPercent: (x) => x.DimensionalPriceConfiguration, + matrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + tieredWithProration: (x) => x.DimensionalPriceConfiguration, + unitWithProration: (x) => x.DimensionalPriceConfiguration, + groupedAllocation: (x) => x.DimensionalPriceConfiguration, + bulkWithProration: (x) => x.DimensionalPriceConfiguration, + groupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, + matrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + groupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + maxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + minimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } + } + + public string? ExternalPriceID + { + get + { + return Match( + unit: (x) => x.ExternalPriceID, + tiered: (x) => x.ExternalPriceID, + bulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + package: (x) => x.ExternalPriceID, + matrix: (x) => x.ExternalPriceID, + thresholdTotalAmount: (x) => x.ExternalPriceID, + tieredPackage: (x) => x.ExternalPriceID, + tieredWithMinimum: (x) => x.ExternalPriceID, + groupedTiered: (x) => x.ExternalPriceID, + tieredPackageWithMinimum: (x) => x.ExternalPriceID, + packageWithAllocation: (x) => x.ExternalPriceID, + unitWithPercent: (x) => x.ExternalPriceID, + matrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + unitWithProration: (x) => x.ExternalPriceID, + groupedAllocation: (x) => x.ExternalPriceID, + bulkWithProration: (x) => x.ExternalPriceID, + groupedWithProratedMinimum: (x) => x.ExternalPriceID, + groupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + matrixWithDisplayName: (x) => x.ExternalPriceID, + groupedTieredPackage: (x) => x.ExternalPriceID, + maxGroupTieredPackage: (x) => x.ExternalPriceID, + scalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + scalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + cumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + minimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } + } + + public double? FixedPriceQuantity + { + get + { + return Match( + unit: (x) => x.FixedPriceQuantity, + tiered: (x) => x.FixedPriceQuantity, + bulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + package: (x) => x.FixedPriceQuantity, + matrix: (x) => x.FixedPriceQuantity, + thresholdTotalAmount: (x) => x.FixedPriceQuantity, + tieredPackage: (x) => x.FixedPriceQuantity, + tieredWithMinimum: (x) => x.FixedPriceQuantity, + groupedTiered: (x) => x.FixedPriceQuantity, + tieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + packageWithAllocation: (x) => x.FixedPriceQuantity, + unitWithPercent: (x) => x.FixedPriceQuantity, + matrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + unitWithProration: (x) => x.FixedPriceQuantity, + groupedAllocation: (x) => x.FixedPriceQuantity, + bulkWithProration: (x) => x.FixedPriceQuantity, + groupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + groupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + matrixWithDisplayName: (x) => x.FixedPriceQuantity, + groupedTieredPackage: (x) => x.FixedPriceQuantity, + maxGroupTieredPackage: (x) => x.FixedPriceQuantity, + scalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + scalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + cumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + minimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } + } + + public string? InvoiceGroupingKey + { + get + { + return Match( + unit: (x) => x.InvoiceGroupingKey, + tiered: (x) => x.InvoiceGroupingKey, + bulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + package: (x) => x.InvoiceGroupingKey, + matrix: (x) => x.InvoiceGroupingKey, + thresholdTotalAmount: (x) => x.InvoiceGroupingKey, + tieredPackage: (x) => x.InvoiceGroupingKey, + tieredWithMinimum: (x) => x.InvoiceGroupingKey, + groupedTiered: (x) => x.InvoiceGroupingKey, + tieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + packageWithAllocation: (x) => x.InvoiceGroupingKey, + unitWithPercent: (x) => x.InvoiceGroupingKey, + matrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + unitWithProration: (x) => x.InvoiceGroupingKey, + groupedAllocation: (x) => x.InvoiceGroupingKey, + bulkWithProration: (x) => x.InvoiceGroupingKey, + groupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + matrixWithDisplayName: (x) => x.InvoiceGroupingKey, + groupedTieredPackage: (x) => x.InvoiceGroupingKey, + maxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + scalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + scalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + cumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } + } + + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + return Match( + unit: (x) => x.InvoicingCycleConfiguration, + tiered: (x) => x.InvoicingCycleConfiguration, + bulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + package: (x) => x.InvoicingCycleConfiguration, + matrix: (x) => x.InvoicingCycleConfiguration, + thresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + tieredPackage: (x) => x.InvoicingCycleConfiguration, + tieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + groupedTiered: (x) => x.InvoicingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + packageWithAllocation: (x) => x.InvoicingCycleConfiguration, + unitWithPercent: (x) => x.InvoicingCycleConfiguration, + matrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + unitWithProration: (x) => x.InvoicingCycleConfiguration, + groupedAllocation: (x) => x.InvoicingCycleConfiguration, + bulkWithProration: (x) => x.InvoicingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + matrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + groupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + maxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + minimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } + } + + public string? LicenseTypeID + { + get + { + return Match( + unit: (x) => x.LicenseTypeID, + tiered: (x) => x.LicenseTypeID, + bulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + package: (x) => x.LicenseTypeID, + matrix: (x) => x.LicenseTypeID, + thresholdTotalAmount: (x) => x.LicenseTypeID, + tieredPackage: (x) => x.LicenseTypeID, + tieredWithMinimum: (x) => x.LicenseTypeID, + groupedTiered: (x) => x.LicenseTypeID, + tieredPackageWithMinimum: (x) => x.LicenseTypeID, + packageWithAllocation: (x) => x.LicenseTypeID, + unitWithPercent: (x) => x.LicenseTypeID, + matrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + unitWithProration: (x) => x.LicenseTypeID, + groupedAllocation: (x) => x.LicenseTypeID, + bulkWithProration: (x) => x.LicenseTypeID, + groupedWithProratedMinimum: (x) => x.LicenseTypeID, + groupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + matrixWithDisplayName: (x) => x.LicenseTypeID, + groupedTieredPackage: (x) => x.LicenseTypeID, + maxGroupTieredPackage: (x) => x.LicenseTypeID, + scalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + scalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + cumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + minimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + + public string? ReferenceID + { + get + { + return Match( + unit: (x) => x.ReferenceID, + tiered: (x) => x.ReferenceID, + bulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + package: (x) => x.ReferenceID, + matrix: (x) => x.ReferenceID, + thresholdTotalAmount: (x) => x.ReferenceID, + tieredPackage: (x) => x.ReferenceID, + tieredWithMinimum: (x) => x.ReferenceID, + groupedTiered: (x) => x.ReferenceID, + tieredPackageWithMinimum: (x) => x.ReferenceID, + packageWithAllocation: (x) => x.ReferenceID, + unitWithPercent: (x) => x.ReferenceID, + matrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + unitWithProration: (x) => x.ReferenceID, + groupedAllocation: (x) => x.ReferenceID, + bulkWithProration: (x) => x.ReferenceID, + groupedWithProratedMinimum: (x) => x.ReferenceID, + groupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + matrixWithDisplayName: (x) => x.ReferenceID, + groupedTieredPackage: (x) => x.ReferenceID, + maxGroupTieredPackage: (x) => x.ReferenceID, + scalableMatrixWithUnitPricing: (x) => x.ReferenceID, + scalableMatrixWithTieredPricing: (x) => x.ReferenceID, + cumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + minimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnit value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTiered value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulk value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulkWithFilters value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePackage value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrix value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceThresholdTotalAmount value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredPackage value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredWithMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedTiered value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePackageWithAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnitWithPercent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrixWithAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnitWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulkWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedTieredPackage value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMinimumComposite value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePercent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceEventOutput value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice(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 `ReplacePriceLicenseAllocationPriceUnit` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceUnit? value) + { + value = this.Value as ReplacePriceLicenseAllocationPriceUnit; + 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 `ReplacePriceLicenseAllocationPriceTiered` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTiered? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTiered; + 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.TryPickBulk(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceBulk` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulk([NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceBulk? value) + { + value = this.Value as ReplacePriceLicenseAllocationPriceBulk; + 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceBulkWithFilters? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceBulkWithFilters; + 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.TryPickPackage(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPricePackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPackage( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPricePackage? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPricePackage; + 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.TryPickMatrix(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMatrix` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrix( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMatrix? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMatrix; + 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.TryPickThresholdTotalAmount(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceThresholdTotalAmount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickThresholdTotalAmount( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceThresholdTotalAmount? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceThresholdTotalAmount; + 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.TryPickTieredPackage(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceTieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredPackage( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTieredPackage? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTieredPackage; + 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.TryPickTieredWithMinimum(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceTieredWithMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithMinimum( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTieredWithMinimum? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTieredWithMinimum; + 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.TryPickGroupedTiered(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedTiered` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedTiered( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedTiered? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedTiered; + 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.TryPickTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredPackageWithMinimum( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum; + 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.TryPickPackageWithAllocation(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPricePackageWithAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPackageWithAllocation( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPricePackageWithAllocation? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPricePackageWithAllocation; + 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.TryPickUnitWithPercent(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceUnitWithPercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnitWithPercent( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceUnitWithPercent? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceUnitWithPercent; + 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.TryPickMatrixWithAllocation(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMatrixWithAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithAllocation( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMatrixWithAllocation? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMatrixWithAllocation; + 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.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTieredWithProration? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTieredWithProration; + 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.TryPickUnitWithProration(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceUnitWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnitWithProration( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceUnitWithProration? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceUnitWithProration; + 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.TryPickGroupedAllocation(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedAllocation( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedAllocation? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedAllocation; + 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.TryPickBulkWithProration(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceBulkWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithProration( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceBulkWithProration? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceBulkWithProration; + 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.TryPickGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithProratedMinimum( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum; + 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.TryPickGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMeteredMinimum( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum; + 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.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds; + 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.TryPickMatrixWithDisplayName(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMatrixWithDisplayName` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithDisplayName( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMatrixWithDisplayName? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMatrixWithDisplayName; + 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.TryPickGroupedTieredPackage(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedTieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedTieredPackage( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedTieredPackage? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedTieredPackage; + 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.TryPickMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMaxGroupTieredPackage( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage; + 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.TryPickScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickScalableMatrixWithUnitPricing( + [NotNullWhen(true)] + out ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing; + 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.TryPickScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickScalableMatrixWithTieredPricing( + [NotNullWhen(true)] + out ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing; + 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.TryPickCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedBulk( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk; + 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 `ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation; + 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.TryPickMinimumComposite(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMinimumComposite` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMinimumComposite( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMinimumComposite? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMinimumComposite; + 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 `ReplacePriceLicenseAllocationPricePercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPricePercent? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPricePercent; + 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 `ReplacePriceLicenseAllocationPriceEventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceEventOutput? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceEventOutput; + 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( + /// (ReplacePriceLicenseAllocationPriceUnit value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTiered value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulk value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulkWithFilters value) => {...}, + /// (ReplacePriceLicenseAllocationPricePackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrix value) => {...}, + /// (ReplacePriceLicenseAllocationPriceThresholdTotalAmount value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredWithMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedTiered value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPricePackageWithAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceUnitWithPercent value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrixWithAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceUnitWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulkWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value) => {...}, + /// (ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value) => {...}, + /// (ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value) => {...}, + /// (ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMinimumComposite value) => {...}, + /// (ReplacePriceLicenseAllocationPricePercent value) => {...}, + /// (ReplacePriceLicenseAllocationPriceEventOutput value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered, + System::Action bulk, + System::Action bulkWithFilters, + System::Action package, + System::Action matrix, + System::Action thresholdTotalAmount, + System::Action tieredPackage, + System::Action tieredWithMinimum, + System::Action groupedTiered, + System::Action tieredPackageWithMinimum, + System::Action packageWithAllocation, + System::Action unitWithPercent, + System::Action matrixWithAllocation, + System::Action tieredWithProration, + System::Action unitWithProration, + System::Action groupedAllocation, + System::Action bulkWithProration, + System::Action groupedWithProratedMinimum, + System::Action groupedWithMeteredMinimum, + System::Action groupedWithMinMaxThresholds, + System::Action matrixWithDisplayName, + System::Action groupedTieredPackage, + System::Action maxGroupTieredPackage, + System::Action scalableMatrixWithUnitPricing, + System::Action scalableMatrixWithTieredPricing, + System::Action cumulativeGroupedBulk, + System::Action cumulativeGroupedAllocation, + System::Action minimumComposite, + System::Action percent, + System::Action eventOutput + ) + { + switch (this.Value) + { + case ReplacePriceLicenseAllocationPriceUnit value: + unit(value); + break; + case ReplacePriceLicenseAllocationPriceTiered value: + tiered(value); + break; + case ReplacePriceLicenseAllocationPriceBulk value: + bulk(value); + break; + case ReplacePriceLicenseAllocationPriceBulkWithFilters value: + bulkWithFilters(value); + break; + case ReplacePriceLicenseAllocationPricePackage value: + package(value); + break; + case ReplacePriceLicenseAllocationPriceMatrix value: + matrix(value); + break; + case ReplacePriceLicenseAllocationPriceThresholdTotalAmount value: + thresholdTotalAmount(value); + break; + case ReplacePriceLicenseAllocationPriceTieredPackage value: + tieredPackage(value); + break; + case ReplacePriceLicenseAllocationPriceTieredWithMinimum value: + tieredWithMinimum(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedTiered value: + groupedTiered(value); + break; + case ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value: + tieredPackageWithMinimum(value); + break; + case ReplacePriceLicenseAllocationPricePackageWithAllocation value: + packageWithAllocation(value); + break; + case ReplacePriceLicenseAllocationPriceUnitWithPercent value: + unitWithPercent(value); + break; + case ReplacePriceLicenseAllocationPriceMatrixWithAllocation value: + matrixWithAllocation(value); + break; + case ReplacePriceLicenseAllocationPriceTieredWithProration value: + tieredWithProration(value); + break; + case ReplacePriceLicenseAllocationPriceUnitWithProration value: + unitWithProration(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedAllocation value: + groupedAllocation(value); + break; + case ReplacePriceLicenseAllocationPriceBulkWithProration value: + bulkWithProration(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value: + groupedWithProratedMinimum(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value: + groupedWithMeteredMinimum(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value: + matrixWithDisplayName(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedTieredPackage value: + groupedTieredPackage(value); + break; + case ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value: + maxGroupTieredPackage(value); + break; + case ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value: + scalableMatrixWithUnitPricing(value); + break; + case ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value: + scalableMatrixWithTieredPricing(value); + break; + case ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value: + cumulativeGroupedBulk(value); + break; + case ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case ReplacePriceLicenseAllocationPriceMinimumComposite value: + minimumComposite(value); + break; + case ReplacePriceLicenseAllocationPricePercent value: + percent(value); + break; + case ReplacePriceLicenseAllocationPriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPrice" + ); + } + } + + /// + /// 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( + /// (ReplacePriceLicenseAllocationPriceUnit value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTiered value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulk value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulkWithFilters value) => {...}, + /// (ReplacePriceLicenseAllocationPricePackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrix value) => {...}, + /// (ReplacePriceLicenseAllocationPriceThresholdTotalAmount value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredWithMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedTiered value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPricePackageWithAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceUnitWithPercent value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrixWithAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceUnitWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulkWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value) => {...}, + /// (ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value) => {...}, + /// (ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value) => {...}, + /// (ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMinimumComposite value) => {...}, + /// (ReplacePriceLicenseAllocationPricePercent value) => {...}, + /// (ReplacePriceLicenseAllocationPriceEventOutput value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered, + System::Func bulk, + System::Func bulkWithFilters, + System::Func package, + System::Func matrix, + System::Func< + ReplacePriceLicenseAllocationPriceThresholdTotalAmount, + T + > thresholdTotalAmount, + System::Func tieredPackage, + System::Func tieredWithMinimum, + System::Func groupedTiered, + System::Func< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum, + T + > tieredPackageWithMinimum, + System::Func< + ReplacePriceLicenseAllocationPricePackageWithAllocation, + T + > packageWithAllocation, + System::Func unitWithPercent, + System::Func< + ReplacePriceLicenseAllocationPriceMatrixWithAllocation, + T + > matrixWithAllocation, + System::Func tieredWithProration, + System::Func unitWithProration, + System::Func groupedAllocation, + System::Func bulkWithProration, + System::Func< + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum, + T + > groupedWithProratedMinimum, + System::Func< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum, + T + > groupedWithMeteredMinimum, + System::Func< + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds, + T + > groupedWithMinMaxThresholds, + System::Func< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName, + T + > matrixWithDisplayName, + System::Func< + ReplacePriceLicenseAllocationPriceGroupedTieredPackage, + T + > groupedTieredPackage, + System::Func< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage, + T + > maxGroupTieredPackage, + System::Func< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing, + T + > scalableMatrixWithUnitPricing, + System::Func< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing, + T + > scalableMatrixWithTieredPricing, + System::Func< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk, + T + > cumulativeGroupedBulk, + System::Func< + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation, + T + > cumulativeGroupedAllocation, + System::Func minimumComposite, + System::Func percent, + System::Func eventOutput + ) + { + return this.Value switch + { + ReplacePriceLicenseAllocationPriceUnit value => unit(value), + ReplacePriceLicenseAllocationPriceTiered value => tiered(value), + ReplacePriceLicenseAllocationPriceBulk value => bulk(value), + ReplacePriceLicenseAllocationPriceBulkWithFilters value => bulkWithFilters(value), + ReplacePriceLicenseAllocationPricePackage value => package(value), + ReplacePriceLicenseAllocationPriceMatrix value => matrix(value), + ReplacePriceLicenseAllocationPriceThresholdTotalAmount value => thresholdTotalAmount( + value + ), + ReplacePriceLicenseAllocationPriceTieredPackage value => tieredPackage(value), + ReplacePriceLicenseAllocationPriceTieredWithMinimum value => tieredWithMinimum(value), + ReplacePriceLicenseAllocationPriceGroupedTiered value => groupedTiered(value), + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value => + tieredPackageWithMinimum(value), + ReplacePriceLicenseAllocationPricePackageWithAllocation value => packageWithAllocation( + value + ), + ReplacePriceLicenseAllocationPriceUnitWithPercent value => unitWithPercent(value), + ReplacePriceLicenseAllocationPriceMatrixWithAllocation value => matrixWithAllocation( + value + ), + ReplacePriceLicenseAllocationPriceTieredWithProration value => tieredWithProration( + value + ), + ReplacePriceLicenseAllocationPriceUnitWithProration value => unitWithProration(value), + ReplacePriceLicenseAllocationPriceGroupedAllocation value => groupedAllocation(value), + ReplacePriceLicenseAllocationPriceBulkWithProration value => bulkWithProration(value), + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value => + groupedWithProratedMinimum(value), + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value => + groupedWithMeteredMinimum(value), + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value => + groupedWithMinMaxThresholds(value), + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value => matrixWithDisplayName( + value + ), + ReplacePriceLicenseAllocationPriceGroupedTieredPackage value => groupedTieredPackage( + value + ), + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value => maxGroupTieredPackage( + value + ), + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value => + scalableMatrixWithUnitPricing(value), + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value => + scalableMatrixWithTieredPricing(value), + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value => cumulativeGroupedBulk( + value + ), + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value => + cumulativeGroupedAllocation(value), + ReplacePriceLicenseAllocationPriceMinimumComposite value => minimumComposite(value), + ReplacePriceLicenseAllocationPricePercent value => percent(value), + ReplacePriceLicenseAllocationPriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPrice" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnit value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTiered value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulk value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulkWithFilters value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePackage value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrix value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceThresholdTotalAmount value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredPackage value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredWithMinimum value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedTiered value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePackageWithAllocation value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnitWithPercent value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrixWithAllocation value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredWithProration value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnitWithProration value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedAllocation value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulkWithProration value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedTieredPackage value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMinimumComposite value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePercent value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceEventOutput 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 ReplacePriceLicenseAllocationPrice" + ); + } + this.Switch( + (unit) => unit.Validate(), + (tiered) => tiered.Validate(), + (bulk) => bulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (package) => package.Validate(), + (matrix) => matrix.Validate(), + (thresholdTotalAmount) => thresholdTotalAmount.Validate(), + (tieredPackage) => tieredPackage.Validate(), + (tieredWithMinimum) => tieredWithMinimum.Validate(), + (groupedTiered) => groupedTiered.Validate(), + (tieredPackageWithMinimum) => tieredPackageWithMinimum.Validate(), + (packageWithAllocation) => packageWithAllocation.Validate(), + (unitWithPercent) => unitWithPercent.Validate(), + (matrixWithAllocation) => matrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (unitWithProration) => unitWithProration.Validate(), + (groupedAllocation) => groupedAllocation.Validate(), + (bulkWithProration) => bulkWithProration.Validate(), + (groupedWithProratedMinimum) => groupedWithProratedMinimum.Validate(), + (groupedWithMeteredMinimum) => groupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (matrixWithDisplayName) => matrixWithDisplayName.Validate(), + (groupedTieredPackage) => groupedTieredPackage.Validate(), + (maxGroupTieredPackage) => maxGroupTieredPackage.Validate(), + (scalableMatrixWithUnitPricing) => scalableMatrixWithUnitPricing.Validate(), + (scalableMatrixWithTieredPricing) => scalableMatrixWithTieredPricing.Validate(), + (cumulativeGroupedBulk) => cumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (minimumComposite) => minimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); + } + + public virtual bool Equals(ReplacePriceLicenseAllocationPrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + ReplacePriceLicenseAllocationPriceUnit _ => 0, + ReplacePriceLicenseAllocationPriceTiered _ => 1, + ReplacePriceLicenseAllocationPriceBulk _ => 2, + ReplacePriceLicenseAllocationPriceBulkWithFilters _ => 3, + ReplacePriceLicenseAllocationPricePackage _ => 4, + ReplacePriceLicenseAllocationPriceMatrix _ => 5, + ReplacePriceLicenseAllocationPriceThresholdTotalAmount _ => 6, + ReplacePriceLicenseAllocationPriceTieredPackage _ => 7, + ReplacePriceLicenseAllocationPriceTieredWithMinimum _ => 8, + ReplacePriceLicenseAllocationPriceGroupedTiered _ => 9, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum _ => 10, + ReplacePriceLicenseAllocationPricePackageWithAllocation _ => 11, + ReplacePriceLicenseAllocationPriceUnitWithPercent _ => 12, + ReplacePriceLicenseAllocationPriceMatrixWithAllocation _ => 13, + ReplacePriceLicenseAllocationPriceTieredWithProration _ => 14, + ReplacePriceLicenseAllocationPriceUnitWithProration _ => 15, + ReplacePriceLicenseAllocationPriceGroupedAllocation _ => 16, + ReplacePriceLicenseAllocationPriceBulkWithProration _ => 17, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum _ => 18, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum _ => 19, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds _ => 20, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName _ => 21, + ReplacePriceLicenseAllocationPriceGroupedTieredPackage _ => 22, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage _ => 23, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing _ => 24, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing _ => 25, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk _ => 26, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation _ => 27, + ReplacePriceLicenseAllocationPriceMinimumComposite _ => 28, + ReplacePriceLicenseAllocationPricePercent _ => 29, + ReplacePriceLicenseAllocationPriceEventOutput _ => 30, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPrice? 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_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 ReplacePriceLicenseAllocationPrice(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPrice? value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value?.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnit, + ReplacePriceLicenseAllocationPriceUnitFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnit : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 unit pricing + /// + public required UnitConfig UnitConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_config"); + } + init { this._rawData.Set("unit_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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("unit"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceUnit() + { + this.ModelType = JsonSerializer.SerializeToElement("unit"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnit( + ReplacePriceLicenseAllocationPriceUnit replacePriceLicenseAllocationPriceUnit + ) + : base(replacePriceLicenseAllocationPriceUnit) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnit(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnit(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnit FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnit FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceUnit.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceUnitCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceUnitCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceUnitCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceUnitCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceUnitCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceUnitCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceUnitCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceUnitCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceUnitCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceUnitCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceUnitCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceUnitCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceUnitCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceUnitCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceUnitCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitLicenseAllocation, + ReplacePriceLicenseAllocationPriceUnitLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceUnitLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitLicenseAllocation( + ReplacePriceLicenseAllocationPriceUnitLicenseAllocation replacePriceLicenseAllocationPriceUnitLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceUnitLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceUnitLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceUnitConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceUnitConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceUnitConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitConversionRateConfig(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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePriceLicenseAllocationPriceUnitConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceUnitConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTiered, + ReplacePriceLicenseAllocationPriceTieredFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTiered : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered pricing + /// + public required TieredConfig TieredConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tiered_config"); + } + init { this._rawData.Set("tiered_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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("tiered"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTiered() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTiered( + ReplacePriceLicenseAllocationPriceTiered replacePriceLicenseAllocationPriceTiered + ) + : base(replacePriceLicenseAllocationPriceTiered) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTiered( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTiered(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTiered FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTiered FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTiered.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceTieredCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceTieredCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceTieredCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceTieredCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceTieredCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceTieredCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceTieredCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredLicenseAllocation replacePriceLicenseAllocationPriceTieredLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredConversionRateConfig(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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulk, + ReplacePriceLicenseAllocationPriceBulkFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulk : JsonModel +{ + /// + /// Configuration for bulk pricing + /// + public required BulkConfig BulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bulk_config"); + } + init { this._rawData.Set("bulk_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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.BulkConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("bulk"))) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceBulk() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulk( + ReplacePriceLicenseAllocationPriceBulk replacePriceLicenseAllocationPriceBulk + ) + : base(replacePriceLicenseAllocationPriceBulk) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulk(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulk(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceBulk.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceBulkCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceBulkCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceBulkCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceBulkCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceBulkCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceBulkCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceBulkCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceBulkCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceBulkCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceBulkCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceBulkCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceBulkCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceBulkCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceBulkCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceBulkCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkLicenseAllocation, + ReplacePriceLicenseAllocationPriceBulkLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceBulkLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkLicenseAllocation( + ReplacePriceLicenseAllocationPriceBulkLicenseAllocation replacePriceLicenseAllocationPriceBulkLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceBulkLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceBulkLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceBulkConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceBulkConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceBulkConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkConversionRateConfig(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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePriceLicenseAllocationPriceBulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceBulkConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFilters, + ReplacePriceLicenseAllocationPriceBulkWithFiltersFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFilters : JsonModel +{ + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig 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, + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFilters( + ReplacePriceLicenseAllocationPriceBulkWithFilters replacePriceLicenseAllocationPriceBulkWithFilters + ) + : base(replacePriceLicenseAllocationPriceBulkWithFilters) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFilters( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + : 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + : 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + : 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation, + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation( + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation replacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackage, + ReplacePriceLicenseAllocationPricePackageFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackage : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 package pricing + /// + public required PackageConfig PackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_config"); + } + init { this._rawData.Set("package_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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("package"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.PackageConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPricePackage() + { + this.ModelType = JsonSerializer.SerializeToElement("package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackage( + ReplacePriceLicenseAllocationPricePackage replacePriceLicenseAllocationPricePackage + ) + : base(replacePriceLicenseAllocationPricePackage) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackage( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePackageCadenceConverter))] +public enum ReplacePriceLicenseAllocationPricePackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPricePackageCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPricePackageCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPricePackageCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPricePackageCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPricePackageCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPricePackageCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPricePackageCadence.Custom, + _ => (ReplacePriceLicenseAllocationPricePackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPricePackageCadence.Annual => "annual", + ReplacePriceLicenseAllocationPricePackageCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPricePackageCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPricePackageCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPricePackageCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPricePackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackageLicenseAllocation, + ReplacePriceLicenseAllocationPricePackageLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPricePackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackageLicenseAllocation( + ReplacePriceLicenseAllocationPricePackageLicenseAllocation replacePriceLicenseAllocationPricePackageLicenseAllocation + ) + : base(replacePriceLicenseAllocationPricePackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackageLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackageLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePackageLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePackageConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPricePackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPricePackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePackageConversionRateConfig(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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPricePackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPricePackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPricePackageConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPricePackageConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePackageConversionRateConfig? 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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrix, + ReplacePriceLicenseAllocationPriceMatrixFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrix : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for matrix pricing + /// + public required MatrixConfig MatrixConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("matrix_config"); + } + init { this._rawData.Set("matrix_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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixConfig.Validate(); + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("matrix"))) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMatrix() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrix( + ReplacePriceLicenseAllocationPriceMatrix replacePriceLicenseAllocationPriceMatrix + ) + : base(replacePriceLicenseAllocationPriceMatrix) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrix( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrix(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrix FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrix FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMatrix.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMatrixCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMatrixCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceMatrixCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMatrixCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMatrixCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMatrixCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMatrixCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMatrixCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMatrixCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMatrixCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceMatrixCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMatrixCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceMatrixCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceMatrixCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation, + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation( + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation replacePriceLicenseAllocationPriceMatrixLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMatrixLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMatrixConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig(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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceThresholdTotalAmount, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceThresholdTotalAmount : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 threshold_total_amount pricing + /// + public required ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig ThresholdTotalAmountConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "threshold_total_amount_config" + ); + } + init { this._rawData.Set("threshold_total_amount_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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("threshold_total_amount") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ThresholdTotalAmountConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmount() + { + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmount( + ReplacePriceLicenseAllocationPriceThresholdTotalAmount replacePriceLicenseAllocationPriceThresholdTotalAmount + ) + : base(replacePriceLicenseAllocationPriceThresholdTotalAmount) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmount( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceThresholdTotalAmount( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceThresholdTotalAmountFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceThresholdTotalAmount.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation replacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for threshold_total_amount pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + : JsonModel +{ + /// + /// When the quantity consumed passes a provided threshold, the configured total + /// will be charged + /// + public required IReadOnlyList ConsumptionTable + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("consumption_table"); + } + init + { + this._rawData.Set< + ImmutableArray + >("consumption_table", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init { this._rawData.Set("prorate", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.ConsumptionTable) + { + item.Validate(); + } + _ = this.Prorate; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig replacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + ) + : base(replacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig( + IReadOnlyList consumptionTable + ) + : this() + { + this.ConsumptionTable = consumptionTable; + } +} + +class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single threshold +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTableFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + : JsonModel +{ + public required string Threshold + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold"); + } + init { this._rawData.Set("threshold", value); } + } + + /// + /// Total amount for this threshold + /// + public required string TotalAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total_amount"); + } + init { this._rawData.Set("total_amount", value); } + } + + /// + public override void Validate() + { + _ = this.Threshold; + _ = this.TotalAmount; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable replacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + ) + : base( + replacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTableFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackage, + ReplacePriceLicenseAllocationPriceTieredPackageFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackage : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered_package pricing + /// + public required ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig TieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_package_config" + ); + } + init { this._rawData.Set("tiered_package_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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackage( + ReplacePriceLicenseAllocationPriceTieredPackage replacePriceLicenseAllocationPriceTieredPackage + ) + : base(replacePriceLicenseAllocationPriceTieredPackage) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackage( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredPackageCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredPackageCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation replacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig, + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + : JsonModel +{ + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. The tier bounds are defined + /// based on the total quantity rather than the number of packages, so they must + /// be multiples of the package size. + /// + 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() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig( + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig replacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + ) + : base(replacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier with business logic +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier, + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + : JsonModel +{ + /// + /// Price per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier( + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier replacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + ) + : base(replacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig(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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithMinimum, + ReplacePriceLicenseAllocationPriceTieredWithMinimumFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithMinimum : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered_with_minimum pricing + /// + public required ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig TieredWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_with_minimum_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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimum( + ReplacePriceLicenseAllocationPriceTieredWithMinimum replacePriceLicenseAllocationPriceTieredWithMinimum + ) + : base(replacePriceLicenseAllocationPriceTieredWithMinimum) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithMinimum( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithMinimum( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithMinimumFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredWithMinimumCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation replacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for tiered_with_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig, + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + : JsonModel +{ + /// + /// Tiered pricing with a minimum amount dependent on the volume tier. Tiers + /// are defined using exclusive lower bounds. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// If true, tiers with an accrued amount of 0 will not be included in the rating. + /// + public bool? HideZeroAmountTiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hide_zero_amount_tiers"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hide_zero_amount_tiers", value); + } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prorate", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.HideZeroAmountTiers; + _ = this.Prorate; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig( + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig replacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + ) + : base(replacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier, + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.MinimumAmount; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier( + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier replacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + ) + : base(replacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTiered, + ReplacePriceLicenseAllocationPriceGroupedTieredFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTiered : 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); } + } + + /// + /// Configuration for grouped_tiered pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig GroupedTieredConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_config" + ); + } + init { this._rawData.Set("grouped_tiered_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedTiered() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTiered( + ReplacePriceLicenseAllocationPriceGroupedTiered replacePriceLicenseAllocationPriceGroupedTiered + ) + : base(replacePriceLicenseAllocationPriceGroupedTiered) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTiered( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTiered(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTiered FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTiered FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedTiered.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceGroupedTieredCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceGroupedTieredCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedTieredCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedTieredCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedTieredCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedTieredCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig, + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + : JsonModel +{ + /// + /// The billable metric property used to group before tiering + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Apply tiered pricing to each segment generated after grouping with the provided key + /// + 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() + { + _ = this.GroupingKey; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig( + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig replacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier, + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier( + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier replacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation replacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig(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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered_package_with_minimum pricing + /// + public required ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig TieredPackageWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_package_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_package_with_minimum_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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum replacePriceLicenseAllocationPriceTieredPackageWithMinimum + ) + : base(replacePriceLicenseAllocationPriceTieredPackageWithMinimum) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation replacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for tiered_package_with_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + : JsonModel +{ + public required double PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + 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() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig replacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + ) + : base( + replacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.MinimumAmount; + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier replacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + ) + : base( + replacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackageWithAllocation, + ReplacePriceLicenseAllocationPricePackageWithAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackageWithAllocation : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 package_with_allocation pricing + /// + public required ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig PackageWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "package_with_allocation_config" + ); + } + init { this._rawData.Set("package_with_allocation_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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("package_with_allocation") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.PackageWithAllocationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackageWithAllocation( + ReplacePriceLicenseAllocationPricePackageWithAllocation replacePriceLicenseAllocationPricePackageWithAllocation + ) + : base(replacePriceLicenseAllocationPricePackageWithAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackageWithAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackageWithAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageWithAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePackageWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePackageWithAllocationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPricePackageWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPricePackageWithAllocationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePackageWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPricePackageWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation, + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation( + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation replacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for package_with_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig, + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + : JsonModel +{ + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + public required string PackageAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_amount"); + } + init { this._rawData.Set("package_amount", value); } + } + + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.PackageAmount; + _ = this.PackageSize; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig( + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig replacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + ) + : base(replacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig? 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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithPercent, + ReplacePriceLicenseAllocationPriceUnitWithPercentFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithPercent : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 unit_with_percent pricing + /// + public required ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig UnitWithPercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "unit_with_percent_config" + ); + } + init { this._rawData.Set("unit_with_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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_percent") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithPercentConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercent() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithPercent( + ReplacePriceLicenseAllocationPriceUnitWithPercent replacePriceLicenseAllocationPriceUnitWithPercent + ) + : base(replacePriceLicenseAllocationPriceUnitWithPercent) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithPercent( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithPercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithPercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithPercentFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithPercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceUnitWithPercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceUnitWithPercentCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceUnitWithPercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceUnitWithPercentCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitWithPercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceUnitWithPercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation, + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation( + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation replacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for unit_with_percent pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig, + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + : JsonModel +{ + /// + /// What percent, out of 100, of the calculated total to charge + /// + public required string Percent + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent"); + } + init { this._rawData.Set("percent", value); } + } + + /// + /// Rate per unit of usage + /// + 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.Percent; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig( + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig replacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + ) + : base(replacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithAllocation, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithAllocation : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for matrix_with_allocation pricing + /// + public required MatrixWithAllocationConfig MatrixWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_allocation_config" + ); + } + init { this._rawData.Set("matrix_with_allocation_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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithAllocationConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithAllocation( + ReplacePriceLicenseAllocationPriceMatrixWithAllocation replacePriceLicenseAllocationPriceMatrixWithAllocation + ) + : base(replacePriceLicenseAllocationPriceMatrixWithAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMatrixWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation( + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation replacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithProration, + ReplacePriceLicenseAllocationPriceTieredWithProrationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithProration : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered_with_proration pricing + /// + public required ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig 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. + /// + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + 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(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProration( + ReplacePriceLicenseAllocationPriceTieredWithProration replacePriceLicenseAllocationPriceTieredWithProration + ) + : base(replacePriceLicenseAllocationPriceTieredWithProration) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithProration( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithProration( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithProrationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredWithProrationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredWithProrationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation replacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig, + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + : 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig( + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig replacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + ) + : base(replacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier replacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + ) + : base(replacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithProration, + ReplacePriceLicenseAllocationPriceUnitWithProrationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithProration : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 unit_with_proration pricing + /// + public required ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig UnitWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "unit_with_proration_config" + ); + } + init { this._rawData.Set("unit_with_proration_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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithProrationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithProration( + ReplacePriceLicenseAllocationPriceUnitWithProration replacePriceLicenseAllocationPriceUnitWithProration + ) + : base(replacePriceLicenseAllocationPriceUnitWithProration) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithProration( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithProration( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithProrationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceUnitWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceUnitWithProrationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceUnitWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceUnitWithProrationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceUnitWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation, + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation( + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation replacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for unit_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig, + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + : JsonModel +{ + /// + /// Rate per unit of usage + /// + 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.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig( + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig replacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + ) + : base(replacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedAllocation, + ReplacePriceLicenseAllocationPriceGroupedAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedAllocation : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_allocation pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig GroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_allocation_config" + ); + } + init { this._rawData.Set("grouped_allocation_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedAllocation( + ReplacePriceLicenseAllocationPriceGroupedAllocation replacePriceLicenseAllocationPriceGroupedAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceGroupedAllocationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedAllocationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig, + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + : JsonModel +{ + /// + /// Usage allocation per group + /// + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + /// + /// How to determine the groups that should each be allocated some quantity + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Unit rate for post-allocation + /// + public required string OverageUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("overage_unit_rate"); + } + init { this._rawData.Set("overage_unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.GroupingKey; + _ = this.OverageUnitRate; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig( + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig replacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + ) + : base(replacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation replacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithProration, + ReplacePriceLicenseAllocationPriceBulkWithProrationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithProration : JsonModel +{ + /// + /// Configuration for bulk_with_proration pricing + /// + public required ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig BulkWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_proration_config" + ); + } + init { this._rawData.Set("bulk_with_proration_config", value); } + } + + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.BulkWithProrationConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("bulk_with_proration") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceBulkWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProration( + ReplacePriceLicenseAllocationPriceBulkWithProration replacePriceLicenseAllocationPriceBulkWithProration + ) + : base(replacePriceLicenseAllocationPriceBulkWithProration) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithProration( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithProration( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithProrationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceBulkWithProration.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig, + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + : JsonModel +{ + /// + /// 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.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig( + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig replacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + ) + : base(replacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single bulk pricing tier with proration +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier, + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + : JsonModel +{ + /// + /// Cost 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier( + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier replacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + ) + : base(replacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceBulkWithProrationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceBulkWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceBulkWithProrationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceBulkWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation, + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation( + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation replacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_with_prorated_minimum pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_prorated_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_prorated_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithProratedMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_prorated_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum replacePriceLicenseAllocationPriceGroupedWithProratedMinimum + ) + : base(replacePriceLicenseAllocationPriceGroupedWithProratedMinimum) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_prorated_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + : JsonModel +{ + /// + /// How to determine the groups that should each have a minimum + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group + /// + public required string Minimum + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum"); + } + init { this._rawData.Set("minimum", value); } + } + + /// + /// The amount to charge per unit + /// + public required string UnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rate"); + } + init { this._rawData.Set("unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.Minimum; + _ = this.UnitRate; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig replacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation replacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_with_metered_minimum pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_metered_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_metered_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMeteredMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_metered_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum replacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + ) + : base(replacePriceLicenseAllocationPriceGroupedWithMeteredMinimum) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_metered_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + : JsonModel +{ + /// + /// Used to partition the usage into groups. The minimum amount is applied to + /// each group. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group per unit + /// + public required string MinimumUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_unit_amount"); + } + init { this._rawData.Set("minimum_unit_amount", value); } + } + + /// + /// Used to determine the unit rate + /// + public required string PricingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_key"); + } + init { this._rawData.Set("pricing_key", value); } + } + + /// + /// Scale the unit rates by the scaling factor. + /// + public required IReadOnlyList ScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Used to determine the unit rate scaling factor + /// + public required string ScalingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_key"); + } + init { this._rawData.Set("scaling_key", value); } + } + + /// + /// Apply per unit pricing to each pricing value. The minimum amount is applied + /// any unmatched usage. + /// + public required IReadOnlyList UnitAmounts + { + 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.GroupingKey; + _ = this.MinimumUnitAmount; + _ = this.PricingKey; + foreach (var item in this.ScalingFactors) + { + item.Validate(); + } + _ = this.ScalingKey; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + : JsonModel +{ + public required string ScalingFactor + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public required string ScalingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_value"); + } + init { this._rawData.Set("scaling_value", value); } + } + + /// + public override void Validate() + { + _ = this.ScalingFactor; + _ = this.ScalingValue; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a unit amount +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + : JsonModel +{ + public required string PricingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_value"); + } + init { this._rawData.Set("pricing_value", 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.PricingValue; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + ) + : base(replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_min_max_thresholds pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayName : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for matrix_with_display_name pricing + /// + public required ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig MatrixWithDisplayNameConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_display_name_config" + ); + } + init { this._rawData.Set("matrix_with_display_name_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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithDisplayNameConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_display_name") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayName() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayName( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName replacePriceLicenseAllocationPriceMatrixWithDisplayName + ) + : base(replacePriceLicenseAllocationPriceMatrixWithDisplayName) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayName( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMatrixWithDisplayName.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation replacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for matrix_with_display_name pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + : 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 + /// + public required IReadOnlyList UnitAmounts + { + 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(); + } + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig replacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + ) + : base(replacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a unit amount item +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + : JsonModel +{ + /// + /// The dimension value + /// + public required string DimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("dimension_value"); + } + init { this._rawData.Set("dimension_value", value); } + } + + /// + /// Display name for this dimension value + /// + public required string DisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("display_name"); + } + 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.DimensionValue; + _ = this.DisplayName; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount replacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + ) + : base( + replacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredPackage, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredPackage : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_tiered_package pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig GroupedTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_package_config" + ); + } + init { this._rawData.Set("grouped_tiered_package_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredPackageConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredPackage( + ReplacePriceLicenseAllocationPriceGroupedTieredPackage replacePriceLicenseAllocationPriceGroupedTieredPackage + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredPackage) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackage( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredPackage( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredPackageFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + : JsonModel +{ + /// + /// The event property used to group before tiering + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + 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() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig replacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + : JsonModel +{ + /// + /// Per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier replacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation replacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for max_group_tiered_package pricing + /// + public required ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig MaxGroupTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "max_group_tiered_package_config" + ); + } + init { this._rawData.Set("max_group_tiered_package_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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MaxGroupTieredPackageConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("max_group_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage replacePriceLicenseAllocationPriceMaxGroupTieredPackage + ) + : base(replacePriceLicenseAllocationPriceMaxGroupTieredPackage) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation replacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for max_group_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + : JsonModel +{ + /// + /// The event property used to group before tiering the group with the highest value + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing to the largest group after grouping with the provided key. + /// + 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() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig replacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + ) + : base(replacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier replacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + ) + : base( + replacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > + >("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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 scalable_matrix_with_unit_pricing pricing + /// + public required ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig 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); } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithUnitPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + ) + : base(replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.OneTime, + "custom" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for scalable_matrix_with_unit_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + : 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 + /// + public required IReadOnlyList MatrixScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// The final unit price to rate against the output of the matrix + /// + public required string UnitPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_price"); + } + init { this._rawData.Set("unit_price", value); } + } + + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init { this._rawData.Set("prorate", value); } + } + + /// + /// Used to determine the unit rate (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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + _ = this.UnitPrice; + _ = this.GroupingKey; + _ = this.Prorate; + _ = this.SecondDimension; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >("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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 scalable_matrix_with_tiered_pricing pricing + /// + public required ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig 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); } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithTieredPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + ) + : base(replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.OneTime, + "custom" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for scalable_matrix_with_tiered_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + : JsonModel +{ + /// + /// Used for the scalable matrix first dimension + /// + 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 + >("matrix_scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.SecondDimension; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier entry with business logic +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + : 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for cumulative_grouped_bulk pricing + /// + public required ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig CumulativeGroupedBulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_bulk_config" + ); + } + init { this._rawData.Set("cumulative_grouped_bulk_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedBulkConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_bulk") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk replacePriceLicenseAllocationPriceCumulativeGroupedBulk + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedBulk) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_bulk pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + : JsonModel +{ + /// + /// Each tier lower bound must have the same group of values. + /// + public required IReadOnlyList DimensionValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("dimension_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("dimension_values", ImmutableArray.ToImmutableArray(value)); + } + } + + public required string Group + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group"); + } + init { this._rawData.Set("group", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.DimensionValues) + { + item.Validate(); + } + _ = this.Group; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig replacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a dimension value entry +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + : JsonModel +{ + /// + /// Grouping key value + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue replacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + ) + : base( + replacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation replacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for cumulative_grouped_allocation pricing + /// + public required ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); + } + init { this._rawData.Set("cumulative_grouped_allocation_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation replacePriceLicenseAllocationPriceCumulativeGroupedAllocation + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel +{ + /// + /// The overall allocation across all groups + /// + public required string CumulativeAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cumulative_allocation"); + } + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", 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.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) + : base( + replacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation replacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMinimumComposite, + ReplacePriceLicenseAllocationPriceMinimumCompositeFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMinimumComposite : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for minimum_composite pricing + /// + public required ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig MinimumCompositeConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "minimum_composite_config" + ); + } + init { this._rawData.Set("minimum_composite_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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MinimumCompositeConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("minimum_composite") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMinimumComposite() + { + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMinimumComposite( + ReplacePriceLicenseAllocationPriceMinimumComposite replacePriceLicenseAllocationPriceMinimumComposite + ) + : base(replacePriceLicenseAllocationPriceMinimumComposite) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMinimumComposite( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMinimumComposite( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMinimumComposite FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMinimumCompositeFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMinimumComposite FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMinimumComposite.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMinimumCompositeCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMinimumCompositeCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMinimumCompositeCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMinimumCompositeCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMinimumCompositeCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation, + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation( + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation replacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for minimum_composite pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig, + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + : 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig( + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig replacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + ) + : base(replacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig( + string minimumAmount + ) + : this() + { + this.MinimumAmount = minimumAmount; + } +} + +class ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePercent, + ReplacePriceLicenseAllocationPricePercentFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePercent : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPricePercentPercentConfig 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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPricePercent() + { + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePercent( + ReplacePriceLicenseAllocationPricePercent replacePriceLicenseAllocationPricePercent + ) + : base(replacePriceLicenseAllocationPricePercent) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePercent( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePercentFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePercentCadenceConverter))] +public enum ReplacePriceLicenseAllocationPricePercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPricePercentCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPricePercentCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPricePercentCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPricePercentCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPricePercentCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPricePercentCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPricePercentCadence.Custom, + _ => (ReplacePriceLicenseAllocationPricePercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPricePercentCadence.Annual => "annual", + ReplacePriceLicenseAllocationPricePercentCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPricePercentCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPricePercentCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPricePercentCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPricePercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePercentLicenseAllocation, + ReplacePriceLicenseAllocationPricePercentLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePercentLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPricePercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePercentLicenseAllocation( + ReplacePriceLicenseAllocationPricePercentLicenseAllocation replacePriceLicenseAllocationPricePercentLicenseAllocation + ) + : base(replacePriceLicenseAllocationPricePercentLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePercentLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePercentLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePercentLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePercentLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for percent pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePercentPercentConfig, + ReplacePriceLicenseAllocationPricePercentPercentConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePercentPercentConfig : 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 ReplacePriceLicenseAllocationPricePercentPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePercentPercentConfig( + ReplacePriceLicenseAllocationPricePercentPercentConfig replacePriceLicenseAllocationPricePercentPercentConfig + ) + : base(replacePriceLicenseAllocationPricePercentPercentConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePercentPercentConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePercentPercentConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePercentPercentConfig(double percent) + : this() + { + this.Percent = percent; + } +} + +class ReplacePriceLicenseAllocationPricePercentPercentConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePercentPercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePercentConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPricePercentConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPricePercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePercentConversionRateConfig(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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPricePercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPricePercentConversionRateConfig( + 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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPricePercentConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPricePercentConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePercentConversionRateConfig? 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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceEventOutput, + ReplacePriceLicenseAllocationPriceEventOutputFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceEventOutput : 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); } + } + + /// + /// Configuration for event_output pricing + /// + public required ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig 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. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceEventOutput() + { + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceEventOutput( + ReplacePriceLicenseAllocationPriceEventOutput replacePriceLicenseAllocationPriceEventOutput + ) + : base(replacePriceLicenseAllocationPriceEventOutput) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceEventOutput( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceEventOutput(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceEventOutputFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceEventOutput.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceEventOutputCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceEventOutputCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceEventOutputCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceEventOutputCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceEventOutputCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceEventOutputCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceEventOutputCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceEventOutputCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceEventOutputCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceEventOutputCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceEventOutputCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceEventOutputCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceEventOutputCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceEventOutputCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceEventOutputCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceEventOutputCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for event_output pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig, + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + : JsonModel +{ + /// + /// The key in the event data to extract the unit rate from. + /// + public required string UnitRatingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + 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.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; + } + + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig( + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig replacePriceLicenseAllocationPriceEventOutputEventOutputConfig + ) + : base(replacePriceLicenseAllocationPriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +class ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation, + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation( + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation replacePriceLicenseAllocationPriceEventOutputLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceEventOutputLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig(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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } } /// diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index 041d6e1a4..4573a3350 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -884,6 +884,21 @@ public NewAllocationPrice? AllocationPrice init { this._rawData.Set("allocation_price", value); } } + /// + /// The license allocation price to add to the plan. + /// + public LicenseAllocationPrice? LicenseAllocationPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_allocation_price" + ); + } + init { this._rawData.Set("license_allocation_price", value); } + } + /// /// The phase to add this price to. /// @@ -914,6 +929,7 @@ public Price? Price public override void Validate() { this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); _ = this.PlanPhaseOrder; this.Price?.Validate(); } @@ -954,10 +970,10 @@ public AddPrice FromRawUnchecked(IReadOnlyDictionary rawDat } /// -/// New plan price request body params. +/// The license allocation price to add to the plan. /// -[JsonConverter(typeof(PriceConverter))] -public record class Price : ModelBase +[JsonConverter(typeof(LicenseAllocationPriceConverter))] +public record class LicenseAllocationPrice : ModelBase { public object? Value { get; } = null; @@ -979,75 +995,115 @@ public string ItemID get { return Match( - newPlanUnit: (x) => x.ItemID, - newPlanTiered: (x) => x.ItemID, - newPlanBulk: (x) => x.ItemID, + unit: (x) => x.ItemID, + tiered: (x) => x.ItemID, + bulk: (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, + package: (x) => x.ItemID, + matrix: (x) => x.ItemID, + thresholdTotalAmount: (x) => x.ItemID, + tieredPackage: (x) => x.ItemID, + tieredWithMinimum: (x) => x.ItemID, + groupedTiered: (x) => x.ItemID, + tieredPackageWithMinimum: (x) => x.ItemID, + packageWithAllocation: (x) => x.ItemID, + unitWithPercent: (x) => x.ItemID, + matrixWithAllocation: (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, + unitWithProration: (x) => x.ItemID, + groupedAllocation: (x) => x.ItemID, + bulkWithProration: (x) => x.ItemID, + groupedWithProratedMinimum: (x) => x.ItemID, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.ItemID, + groupedTieredPackage: (x) => x.ItemID, + maxGroupTieredPackage: (x) => x.ItemID, + scalableMatrixWithUnitPricing: (x) => x.ItemID, + scalableMatrixWithTieredPricing: (x) => x.ItemID, + cumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - newPlanMinimumComposite: (x) => x.ItemID, + minimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID ); } } + public JsonElement ModelType + { + get + { + return Match( + unit: (x) => x.ModelType, + tiered: (x) => x.ModelType, + bulk: (x) => x.ModelType, + bulkWithFilters: (x) => x.ModelType, + package: (x) => x.ModelType, + matrix: (x) => x.ModelType, + thresholdTotalAmount: (x) => x.ModelType, + tieredPackage: (x) => x.ModelType, + tieredWithMinimum: (x) => x.ModelType, + groupedTiered: (x) => x.ModelType, + tieredPackageWithMinimum: (x) => x.ModelType, + packageWithAllocation: (x) => x.ModelType, + unitWithPercent: (x) => x.ModelType, + matrixWithAllocation: (x) => x.ModelType, + tieredWithProration: (x) => x.ModelType, + unitWithProration: (x) => x.ModelType, + groupedAllocation: (x) => x.ModelType, + bulkWithProration: (x) => x.ModelType, + groupedWithProratedMinimum: (x) => x.ModelType, + groupedWithMeteredMinimum: (x) => x.ModelType, + groupedWithMinMaxThresholds: (x) => x.ModelType, + matrixWithDisplayName: (x) => x.ModelType, + groupedTieredPackage: (x) => x.ModelType, + maxGroupTieredPackage: (x) => x.ModelType, + scalableMatrixWithUnitPricing: (x) => x.ModelType, + scalableMatrixWithTieredPricing: (x) => x.ModelType, + cumulativeGroupedBulk: (x) => x.ModelType, + cumulativeGroupedAllocation: (x) => x.ModelType, + minimumComposite: (x) => x.ModelType, + percent: (x) => x.ModelType, + eventOutput: (x) => x.ModelType + ); + } + } + public string Name { get { return Match( - newPlanUnit: (x) => x.Name, - newPlanTiered: (x) => x.Name, - newPlanBulk: (x) => x.Name, + unit: (x) => x.Name, + tiered: (x) => x.Name, + bulk: (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, + package: (x) => x.Name, + matrix: (x) => x.Name, + thresholdTotalAmount: (x) => x.Name, + tieredPackage: (x) => x.Name, + tieredWithMinimum: (x) => x.Name, + groupedTiered: (x) => x.Name, + tieredPackageWithMinimum: (x) => x.Name, + packageWithAllocation: (x) => x.Name, + unitWithPercent: (x) => x.Name, + matrixWithAllocation: (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, + unitWithProration: (x) => x.Name, + groupedAllocation: (x) => x.Name, + bulkWithProration: (x) => x.Name, + groupedWithProratedMinimum: (x) => x.Name, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.Name, + groupedTieredPackage: (x) => x.Name, + maxGroupTieredPackage: (x) => x.Name, + scalableMatrixWithUnitPricing: (x) => x.Name, + scalableMatrixWithTieredPricing: (x) => x.Name, + cumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, + minimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name ); @@ -1059,35 +1115,35 @@ public string? BillableMetricID get { return Match( - newPlanUnit: (x) => x.BillableMetricID, - newPlanTiered: (x) => x.BillableMetricID, - newPlanBulk: (x) => x.BillableMetricID, + unit: (x) => x.BillableMetricID, + tiered: (x) => x.BillableMetricID, + bulk: (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, + package: (x) => x.BillableMetricID, + matrix: (x) => x.BillableMetricID, + thresholdTotalAmount: (x) => x.BillableMetricID, + tieredPackage: (x) => x.BillableMetricID, + tieredWithMinimum: (x) => x.BillableMetricID, + groupedTiered: (x) => x.BillableMetricID, + tieredPackageWithMinimum: (x) => x.BillableMetricID, + packageWithAllocation: (x) => x.BillableMetricID, + unitWithPercent: (x) => x.BillableMetricID, + matrixWithAllocation: (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, + unitWithProration: (x) => x.BillableMetricID, + groupedAllocation: (x) => x.BillableMetricID, + bulkWithProration: (x) => x.BillableMetricID, + groupedWithProratedMinimum: (x) => x.BillableMetricID, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.BillableMetricID, + groupedTieredPackage: (x) => x.BillableMetricID, + maxGroupTieredPackage: (x) => x.BillableMetricID, + scalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + scalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + cumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, + minimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID ); @@ -1099,35 +1155,35 @@ public bool? BilledInAdvance get { return Match( - newPlanUnit: (x) => x.BilledInAdvance, - newPlanTiered: (x) => x.BilledInAdvance, - newPlanBulk: (x) => x.BilledInAdvance, + unit: (x) => x.BilledInAdvance, + tiered: (x) => x.BilledInAdvance, + bulk: (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, + package: (x) => x.BilledInAdvance, + matrix: (x) => x.BilledInAdvance, + thresholdTotalAmount: (x) => x.BilledInAdvance, + tieredPackage: (x) => x.BilledInAdvance, + tieredWithMinimum: (x) => x.BilledInAdvance, + groupedTiered: (x) => x.BilledInAdvance, + tieredPackageWithMinimum: (x) => x.BilledInAdvance, + packageWithAllocation: (x) => x.BilledInAdvance, + unitWithPercent: (x) => x.BilledInAdvance, + matrixWithAllocation: (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, + unitWithProration: (x) => x.BilledInAdvance, + groupedAllocation: (x) => x.BilledInAdvance, + bulkWithProration: (x) => x.BilledInAdvance, + groupedWithProratedMinimum: (x) => x.BilledInAdvance, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.BilledInAdvance, + groupedTieredPackage: (x) => x.BilledInAdvance, + maxGroupTieredPackage: (x) => x.BilledInAdvance, + scalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + scalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + cumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, + minimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance ); @@ -1139,35 +1195,35 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration get { return Match( - newPlanUnit: (x) => x.BillingCycleConfiguration, - newPlanTiered: (x) => x.BillingCycleConfiguration, - newPlanBulk: (x) => x.BillingCycleConfiguration, + unit: (x) => x.BillingCycleConfiguration, + tiered: (x) => x.BillingCycleConfiguration, + bulk: (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, + package: (x) => x.BillingCycleConfiguration, + matrix: (x) => x.BillingCycleConfiguration, + thresholdTotalAmount: (x) => x.BillingCycleConfiguration, + tieredPackage: (x) => x.BillingCycleConfiguration, + tieredWithMinimum: (x) => x.BillingCycleConfiguration, + groupedTiered: (x) => x.BillingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + packageWithAllocation: (x) => x.BillingCycleConfiguration, + unitWithPercent: (x) => x.BillingCycleConfiguration, + matrixWithAllocation: (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, + unitWithProration: (x) => x.BillingCycleConfiguration, + groupedAllocation: (x) => x.BillingCycleConfiguration, + bulkWithProration: (x) => x.BillingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.BillingCycleConfiguration, + groupedTieredPackage: (x) => x.BillingCycleConfiguration, + maxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, + minimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration ); @@ -1179,35 +1235,35 @@ public double? ConversionRate get { return Match( - newPlanUnit: (x) => x.ConversionRate, - newPlanTiered: (x) => x.ConversionRate, - newPlanBulk: (x) => x.ConversionRate, + unit: (x) => x.ConversionRate, + tiered: (x) => x.ConversionRate, + bulk: (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, + package: (x) => x.ConversionRate, + matrix: (x) => x.ConversionRate, + thresholdTotalAmount: (x) => x.ConversionRate, + tieredPackage: (x) => x.ConversionRate, + tieredWithMinimum: (x) => x.ConversionRate, + groupedTiered: (x) => x.ConversionRate, + tieredPackageWithMinimum: (x) => x.ConversionRate, + packageWithAllocation: (x) => x.ConversionRate, + unitWithPercent: (x) => x.ConversionRate, + matrixWithAllocation: (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, + unitWithProration: (x) => x.ConversionRate, + groupedAllocation: (x) => x.ConversionRate, + bulkWithProration: (x) => x.ConversionRate, + groupedWithProratedMinimum: (x) => x.ConversionRate, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.ConversionRate, + groupedTieredPackage: (x) => x.ConversionRate, + maxGroupTieredPackage: (x) => x.ConversionRate, + scalableMatrixWithUnitPricing: (x) => x.ConversionRate, + scalableMatrixWithTieredPricing: (x) => x.ConversionRate, + cumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, + minimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate ); @@ -1219,35 +1275,35 @@ public string? Currency get { return Match( - newPlanUnit: (x) => x.Currency, - newPlanTiered: (x) => x.Currency, - newPlanBulk: (x) => x.Currency, + unit: (x) => x.Currency, + tiered: (x) => x.Currency, + bulk: (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, + package: (x) => x.Currency, + matrix: (x) => x.Currency, + thresholdTotalAmount: (x) => x.Currency, + tieredPackage: (x) => x.Currency, + tieredWithMinimum: (x) => x.Currency, + groupedTiered: (x) => x.Currency, + tieredPackageWithMinimum: (x) => x.Currency, + packageWithAllocation: (x) => x.Currency, + unitWithPercent: (x) => x.Currency, + matrixWithAllocation: (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, + unitWithProration: (x) => x.Currency, + groupedAllocation: (x) => x.Currency, + bulkWithProration: (x) => x.Currency, + groupedWithProratedMinimum: (x) => x.Currency, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.Currency, + groupedTieredPackage: (x) => x.Currency, + maxGroupTieredPackage: (x) => x.Currency, + scalableMatrixWithUnitPricing: (x) => x.Currency, + scalableMatrixWithTieredPricing: (x) => x.Currency, + cumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, + minimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency ); @@ -1259,35 +1315,35 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration get { return Match( - newPlanUnit: (x) => x.DimensionalPriceConfiguration, - newPlanTiered: (x) => x.DimensionalPriceConfiguration, - newPlanBulk: (x) => x.DimensionalPriceConfiguration, + unit: (x) => x.DimensionalPriceConfiguration, + tiered: (x) => x.DimensionalPriceConfiguration, + bulk: (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, + package: (x) => x.DimensionalPriceConfiguration, + matrix: (x) => x.DimensionalPriceConfiguration, + thresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + tieredPackage: (x) => x.DimensionalPriceConfiguration, + tieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + groupedTiered: (x) => x.DimensionalPriceConfiguration, + tieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + packageWithAllocation: (x) => x.DimensionalPriceConfiguration, + unitWithPercent: (x) => x.DimensionalPriceConfiguration, + matrixWithAllocation: (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, + unitWithProration: (x) => x.DimensionalPriceConfiguration, + groupedAllocation: (x) => x.DimensionalPriceConfiguration, + bulkWithProration: (x) => x.DimensionalPriceConfiguration, + groupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + groupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + maxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + minimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration ); @@ -1299,35 +1355,35 @@ public string? ExternalPriceID get { return Match( - newPlanUnit: (x) => x.ExternalPriceID, - newPlanTiered: (x) => x.ExternalPriceID, - newPlanBulk: (x) => x.ExternalPriceID, + unit: (x) => x.ExternalPriceID, + tiered: (x) => x.ExternalPriceID, + bulk: (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, + package: (x) => x.ExternalPriceID, + matrix: (x) => x.ExternalPriceID, + thresholdTotalAmount: (x) => x.ExternalPriceID, + tieredPackage: (x) => x.ExternalPriceID, + tieredWithMinimum: (x) => x.ExternalPriceID, + groupedTiered: (x) => x.ExternalPriceID, + tieredPackageWithMinimum: (x) => x.ExternalPriceID, + packageWithAllocation: (x) => x.ExternalPriceID, + unitWithPercent: (x) => x.ExternalPriceID, + matrixWithAllocation: (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, + unitWithProration: (x) => x.ExternalPriceID, + groupedAllocation: (x) => x.ExternalPriceID, + bulkWithProration: (x) => x.ExternalPriceID, + groupedWithProratedMinimum: (x) => x.ExternalPriceID, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.ExternalPriceID, + groupedTieredPackage: (x) => x.ExternalPriceID, + maxGroupTieredPackage: (x) => x.ExternalPriceID, + scalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + scalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + cumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, + minimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID ); @@ -1339,35 +1395,35 @@ public double? FixedPriceQuantity get { return Match( - newPlanUnit: (x) => x.FixedPriceQuantity, - newPlanTiered: (x) => x.FixedPriceQuantity, - newPlanBulk: (x) => x.FixedPriceQuantity, + unit: (x) => x.FixedPriceQuantity, + tiered: (x) => x.FixedPriceQuantity, + bulk: (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, + package: (x) => x.FixedPriceQuantity, + matrix: (x) => x.FixedPriceQuantity, + thresholdTotalAmount: (x) => x.FixedPriceQuantity, + tieredPackage: (x) => x.FixedPriceQuantity, + tieredWithMinimum: (x) => x.FixedPriceQuantity, + groupedTiered: (x) => x.FixedPriceQuantity, + tieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + packageWithAllocation: (x) => x.FixedPriceQuantity, + unitWithPercent: (x) => x.FixedPriceQuantity, + matrixWithAllocation: (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, + unitWithProration: (x) => x.FixedPriceQuantity, + groupedAllocation: (x) => x.FixedPriceQuantity, + bulkWithProration: (x) => x.FixedPriceQuantity, + groupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.FixedPriceQuantity, + groupedTieredPackage: (x) => x.FixedPriceQuantity, + maxGroupTieredPackage: (x) => x.FixedPriceQuantity, + scalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + scalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + cumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + minimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity ); @@ -1379,35 +1435,35 @@ public string? InvoiceGroupingKey get { return Match( - newPlanUnit: (x) => x.InvoiceGroupingKey, - newPlanTiered: (x) => x.InvoiceGroupingKey, - newPlanBulk: (x) => x.InvoiceGroupingKey, + unit: (x) => x.InvoiceGroupingKey, + tiered: (x) => x.InvoiceGroupingKey, + bulk: (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, + package: (x) => x.InvoiceGroupingKey, + matrix: (x) => x.InvoiceGroupingKey, + thresholdTotalAmount: (x) => x.InvoiceGroupingKey, + tieredPackage: (x) => x.InvoiceGroupingKey, + tieredWithMinimum: (x) => x.InvoiceGroupingKey, + groupedTiered: (x) => x.InvoiceGroupingKey, + tieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + packageWithAllocation: (x) => x.InvoiceGroupingKey, + unitWithPercent: (x) => x.InvoiceGroupingKey, + matrixWithAllocation: (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, + unitWithProration: (x) => x.InvoiceGroupingKey, + groupedAllocation: (x) => x.InvoiceGroupingKey, + bulkWithProration: (x) => x.InvoiceGroupingKey, + groupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.InvoiceGroupingKey, + groupedTieredPackage: (x) => x.InvoiceGroupingKey, + maxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + scalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + scalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + cumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey ); @@ -1419,35 +1475,35 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration get { return Match( - newPlanUnit: (x) => x.InvoicingCycleConfiguration, - newPlanTiered: (x) => x.InvoicingCycleConfiguration, - newPlanBulk: (x) => x.InvoicingCycleConfiguration, + unit: (x) => x.InvoicingCycleConfiguration, + tiered: (x) => x.InvoicingCycleConfiguration, + bulk: (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, + package: (x) => x.InvoicingCycleConfiguration, + matrix: (x) => x.InvoicingCycleConfiguration, + thresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + tieredPackage: (x) => x.InvoicingCycleConfiguration, + tieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + groupedTiered: (x) => x.InvoicingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + packageWithAllocation: (x) => x.InvoicingCycleConfiguration, + unitWithPercent: (x) => x.InvoicingCycleConfiguration, + matrixWithAllocation: (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, + unitWithProration: (x) => x.InvoicingCycleConfiguration, + groupedAllocation: (x) => x.InvoicingCycleConfiguration, + bulkWithProration: (x) => x.InvoicingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + groupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + maxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + minimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration ); @@ -1459,35 +1515,35 @@ public string? LicenseTypeID get { return Match( - newPlanUnit: (x) => x.LicenseTypeID, - newPlanTiered: (x) => x.LicenseTypeID, - newPlanBulk: (x) => x.LicenseTypeID, + unit: (x) => x.LicenseTypeID, + tiered: (x) => x.LicenseTypeID, + bulk: (x) => x.LicenseTypeID, bulkWithFilters: (x) => x.LicenseTypeID, - newPlanPackage: (x) => x.LicenseTypeID, - newPlanMatrix: (x) => x.LicenseTypeID, - newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, - newPlanTieredPackage: (x) => x.LicenseTypeID, - newPlanTieredWithMinimum: (x) => x.LicenseTypeID, - newPlanGroupedTiered: (x) => x.LicenseTypeID, - newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, - newPlanPackageWithAllocation: (x) => x.LicenseTypeID, - newPlanUnitWithPercent: (x) => x.LicenseTypeID, - newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + package: (x) => x.LicenseTypeID, + matrix: (x) => x.LicenseTypeID, + thresholdTotalAmount: (x) => x.LicenseTypeID, + tieredPackage: (x) => x.LicenseTypeID, + tieredWithMinimum: (x) => x.LicenseTypeID, + groupedTiered: (x) => x.LicenseTypeID, + tieredPackageWithMinimum: (x) => x.LicenseTypeID, + packageWithAllocation: (x) => x.LicenseTypeID, + unitWithPercent: (x) => x.LicenseTypeID, + matrixWithAllocation: (x) => x.LicenseTypeID, tieredWithProration: (x) => x.LicenseTypeID, - newPlanUnitWithProration: (x) => x.LicenseTypeID, - newPlanGroupedAllocation: (x) => x.LicenseTypeID, - newPlanBulkWithProration: (x) => x.LicenseTypeID, - newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, - newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + unitWithProration: (x) => x.LicenseTypeID, + groupedAllocation: (x) => x.LicenseTypeID, + bulkWithProration: (x) => x.LicenseTypeID, + groupedWithProratedMinimum: (x) => x.LicenseTypeID, + groupedWithMeteredMinimum: (x) => x.LicenseTypeID, groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, - newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, - newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, - newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, - newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, - newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, - newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + matrixWithDisplayName: (x) => x.LicenseTypeID, + groupedTieredPackage: (x) => x.LicenseTypeID, + maxGroupTieredPackage: (x) => x.LicenseTypeID, + scalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + scalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + cumulativeGroupedBulk: (x) => x.LicenseTypeID, cumulativeGroupedAllocation: (x) => x.LicenseTypeID, - newPlanMinimumComposite: (x) => x.LicenseTypeID, + minimumComposite: (x) => x.LicenseTypeID, percent: (x) => x.LicenseTypeID, eventOutput: (x) => x.LicenseTypeID ); @@ -1499,292 +1555,295 @@ public string? ReferenceID get { return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, + unit: (x) => x.ReferenceID, + tiered: (x) => x.ReferenceID, + bulk: (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, + package: (x) => x.ReferenceID, + matrix: (x) => x.ReferenceID, + thresholdTotalAmount: (x) => x.ReferenceID, + tieredPackage: (x) => x.ReferenceID, + tieredWithMinimum: (x) => x.ReferenceID, + groupedTiered: (x) => x.ReferenceID, + tieredPackageWithMinimum: (x) => x.ReferenceID, + packageWithAllocation: (x) => x.ReferenceID, + unitWithPercent: (x) => x.ReferenceID, + matrixWithAllocation: (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, + unitWithProration: (x) => x.ReferenceID, + groupedAllocation: (x) => x.ReferenceID, + bulkWithProration: (x) => x.ReferenceID, + groupedWithProratedMinimum: (x) => x.ReferenceID, + groupedWithMeteredMinimum: (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, + matrixWithDisplayName: (x) => x.ReferenceID, + groupedTieredPackage: (x) => x.ReferenceID, + maxGroupTieredPackage: (x) => x.ReferenceID, + scalableMatrixWithUnitPricing: (x) => x.ReferenceID, + scalableMatrixWithTieredPricing: (x) => x.ReferenceID, + cumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, + minimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID ); } } - public Price(NewPlanUnitPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Unit value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Tiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Bulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(BulkWithFilters value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(Package value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Matrix value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + public LicenseAllocationPrice(ThresholdTotalAmount value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackageWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(PackageWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithPercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(TieredWithProration value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithProratedMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithMeteredMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(GroupedWithMinMaxThresholds value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithDisplayName value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MaxGroupTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice(ScalableMatrixWithUnitPricing value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanScalableMatrixWithTieredPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice( + ScalableMatrixWithTieredPricing value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice(CumulativeGroupedBulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(CumulativeGroupedAllocation value, JsonElement? element = null) + public LicenseAllocationPrice(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MinimumComposite value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(Percent value, JsonElement? element = null) + public LicenseAllocationPrice(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(EventOutput value, JsonElement? element = null) + public LicenseAllocationPrice(EventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(JsonElement element) + public LicenseAllocationPrice(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.TryPickNewPlanUnit(out var value)) { - /// // `value` is of type `NewPlanUnitPrice` + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `Unit` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + public bool TryPickUnit([NotNullWhen(true)] out Unit? value) { - value = this.Value as NewPlanUnitPrice; + value = this.Value as Unit; 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.TryPickTiered(out var value)) { + /// // `value` is of type `Tiered` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + public bool TryPickTiered([NotNullWhen(true)] out Tiered? value) { - value = this.Value as NewPlanTieredPrice; + value = this.Value as Tiered; 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.TryPickBulk(out var value)) { + /// // `value` is of type `Bulk` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + public bool TryPickBulk([NotNullWhen(true)] out Bulk? value) { - value = this.Value as NewPlanBulkPrice; + value = this.Value as Bulk; return value != null; } @@ -1811,227 +1870,213 @@ public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? valu /// /// 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.TryPickPackage(out var value)) { + /// // `value` is of type `Package` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + public bool TryPickPackage([NotNullWhen(true)] out Package? value) { - value = this.Value as NewPlanPackagePrice; + value = this.Value as Package; 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.TryPickMatrix(out var value)) { + /// // `value` is of type `Matrix` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + public bool TryPickMatrix([NotNullWhen(true)] out Matrix? value) { - value = this.Value as NewPlanMatrixPrice; + value = this.Value as Matrix; 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.TryPickThresholdTotalAmount(out var value)) { + /// // `value` is of type `ThresholdTotalAmount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) + public bool TryPickThresholdTotalAmount([NotNullWhen(true)] out ThresholdTotalAmount? value) { - value = this.Value as NewPlanThresholdTotalAmountPrice; + value = this.Value as ThresholdTotalAmount; 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.TryPickTieredPackage(out var value)) { + /// // `value` is of type `TieredPackage` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredPackage( - [NotNullWhen(true)] out NewPlanTieredPackagePrice? value - ) + public bool TryPickTieredPackage([NotNullWhen(true)] out TieredPackage? value) { - value = this.Value as NewPlanTieredPackagePrice; + value = this.Value as TieredPackage; 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.TryPickTieredWithMinimum(out var value)) { + /// // `value` is of type `TieredWithMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredWithMinimum( - [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value - ) + public bool TryPickTieredWithMinimum([NotNullWhen(true)] out TieredWithMinimum? value) { - value = this.Value as NewPlanTieredWithMinimumPrice; + value = this.Value as TieredWithMinimum; 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.TryPickGroupedTiered(out var value)) { + /// // `value` is of type `GroupedTiered` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value - ) + public bool TryPickGroupedTiered([NotNullWhen(true)] out GroupedTiered? value) { - value = this.Value as NewPlanGroupedTieredPrice; + value = this.Value as GroupedTiered; 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.TryPickTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `TieredPackageWithMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + public bool TryPickTieredPackageWithMinimum( + [NotNullWhen(true)] out TieredPackageWithMinimum? value ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; + value = this.Value as TieredPackageWithMinimum; 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.TryPickPackageWithAllocation(out var value)) { + /// // `value` is of type `PackageWithAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value - ) + public bool TryPickPackageWithAllocation([NotNullWhen(true)] out PackageWithAllocation? value) { - value = this.Value as NewPlanPackageWithAllocationPrice; + value = this.Value as PackageWithAllocation; 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.TryPickUnitWithPercent(out var value)) { + /// // `value` is of type `UnitWithPercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value - ) + public bool TryPickUnitWithPercent([NotNullWhen(true)] out UnitWithPercent? value) { - value = this.Value as NewPlanUnitWithPercentPrice; + value = this.Value as UnitWithPercent; 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.TryPickMatrixWithAllocation(out var value)) { + /// // `value` is of type `MatrixWithAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrixWithAllocation( - [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value - ) + public bool TryPickMatrixWithAllocation([NotNullWhen(true)] out MatrixWithAllocation? value) { - value = this.Value as NewPlanMatrixWithAllocationPrice; + value = this.Value as MatrixWithAllocation; return value != null; } @@ -2058,116 +2103,110 @@ public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProrati /// /// 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.TryPickUnitWithProration(out var value)) { + /// // `value` is of type `UnitWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public bool TryPickUnitWithProration([NotNullWhen(true)] out UnitWithProration? value) { - value = this.Value as NewPlanUnitWithProrationPrice; + value = this.Value as UnitWithProration; 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.TryPickGroupedAllocation(out var value)) { + /// // `value` is of type `GroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + public bool TryPickGroupedAllocation([NotNullWhen(true)] out GroupedAllocation? value) { - value = this.Value as NewPlanGroupedAllocationPrice; + value = this.Value as GroupedAllocation; 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.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` + /// if (instance.TryPickBulkWithProration(out var value)) { + /// // `value` is of type `BulkWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) + public bool TryPickBulkWithProration([NotNullWhen(true)] out BulkWithProration? value) { - value = this.Value as NewPlanBulkWithProrationPrice; + value = this.Value as BulkWithProration; 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.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` + /// if (instance.TryPickGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `GroupedWithProratedMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + public bool TryPickGroupedWithProratedMinimum( + [NotNullWhen(true)] out GroupedWithProratedMinimum? value ) { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; + value = this.Value as GroupedWithProratedMinimum; 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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` + /// if (instance.TryPickGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `GroupedWithMeteredMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + public bool TryPickGroupedWithMeteredMinimum( + [NotNullWhen(true)] out GroupedWithMeteredMinimum? value ) { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; + value = this.Value as GroupedWithMeteredMinimum; return value != null; } @@ -2196,139 +2235,131 @@ public bool TryPickGroupedWithMinMaxThresholds( /// /// 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.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` + /// if (instance.TryPickMatrixWithDisplayName(out var value)) { + /// // `value` is of type `MatrixWithDisplayName` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public bool TryPickMatrixWithDisplayName([NotNullWhen(true)] out MatrixWithDisplayName? value) { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; + value = this.Value as MatrixWithDisplayName; 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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` + /// if (instance.TryPickGroupedTieredPackage(out var value)) { + /// // `value` is of type `GroupedTieredPackage` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public bool TryPickGroupedTieredPackage([NotNullWhen(true)] out GroupedTieredPackage? value) { - value = this.Value as NewPlanGroupedTieredPackagePrice; + value = this.Value as GroupedTieredPackage; 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` + /// if (instance.TryPickMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `MaxGroupTieredPackage` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public bool TryPickMaxGroupTieredPackage([NotNullWhen(true)] out MaxGroupTieredPackage? value) { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; + value = this.Value as MaxGroupTieredPackage; 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.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` + /// if (instance.TryPickScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `ScalableMatrixWithUnitPricing` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value + public bool TryPickScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out ScalableMatrixWithUnitPricing? value ) { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; + value = this.Value as ScalableMatrixWithUnitPricing; 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.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` + /// if (instance.TryPickScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `ScalableMatrixWithTieredPricing` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value + public bool TryPickScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out ScalableMatrixWithTieredPricing? value ) { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; + value = this.Value as ScalableMatrixWithTieredPricing; 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.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` + /// if (instance.TryPickCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `CumulativeGroupedBulk` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public bool TryPickCumulativeGroupedBulk([NotNullWhen(true)] out CumulativeGroupedBulk? value) { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; + value = this.Value as CumulativeGroupedBulk; return value != null; } @@ -2357,24 +2388,22 @@ public bool TryPickCumulativeGroupedAllocation( /// /// 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.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` + /// if (instance.TryPickMinimumComposite(out var value)) { + /// // `value` is of type `MinimumComposite` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + public bool TryPickMinimumComposite([NotNullWhen(true)] out MinimumComposite? value) { - value = this.Value as NewPlanMinimumCompositePrice; + value = this.Value as MinimumComposite; return value != null; } @@ -2434,35 +2463,35 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// /// /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, + /// (Unit value) => {...}, + /// (Tiered value) => {...}, + /// (Bulk value) => {...}, /// (BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (Package value) => {...}, + /// (Matrix value) => {...}, + /// (ThresholdTotalAmount value) => {...}, + /// (TieredPackage value) => {...}, + /// (TieredWithMinimum value) => {...}, + /// (GroupedTiered value) => {...}, + /// (TieredPackageWithMinimum value) => {...}, + /// (PackageWithAllocation value) => {...}, + /// (UnitWithPercent value) => {...}, + /// (MatrixWithAllocation value) => {...}, /// (TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (UnitWithProration value) => {...}, + /// (GroupedAllocation value) => {...}, + /// (BulkWithProration value) => {...}, + /// (GroupedWithProratedMinimum value) => {...}, + /// (GroupedWithMeteredMinimum value) => {...}, /// (GroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (MatrixWithDisplayName value) => {...}, + /// (GroupedTieredPackage value) => {...}, + /// (MaxGroupTieredPackage value) => {...}, + /// (ScalableMatrixWithUnitPricing value) => {...}, + /// (ScalableMatrixWithTieredPricing value) => {...}, + /// (CumulativeGroupedBulk value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, + /// (MinimumComposite value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} /// ); @@ -2470,127 +2499,127 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// /// public void Switch( - System::Action newPlanUnit, - System::Action newPlanTiered, - System::Action newPlanBulk, + System::Action unit, + System::Action tiered, + System::Action bulk, 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 package, + System::Action matrix, + System::Action thresholdTotalAmount, + System::Action tieredPackage, + System::Action tieredWithMinimum, + System::Action groupedTiered, + System::Action tieredPackageWithMinimum, + System::Action packageWithAllocation, + System::Action unitWithPercent, + System::Action matrixWithAllocation, System::Action tieredWithProration, - System::Action newPlanUnitWithProration, - System::Action newPlanGroupedAllocation, - System::Action newPlanBulkWithProration, - System::Action newPlanGroupedWithProratedMinimum, - System::Action newPlanGroupedWithMeteredMinimum, + System::Action unitWithProration, + System::Action groupedAllocation, + System::Action bulkWithProration, + System::Action groupedWithProratedMinimum, + System::Action groupedWithMeteredMinimum, System::Action groupedWithMinMaxThresholds, - System::Action newPlanMatrixWithDisplayName, - System::Action newPlanGroupedTieredPackage, - System::Action newPlanMaxGroupTieredPackage, - System::Action newPlanScalableMatrixWithUnitPricing, - System::Action newPlanScalableMatrixWithTieredPricing, - System::Action newPlanCumulativeGroupedBulk, + System::Action matrixWithDisplayName, + System::Action groupedTieredPackage, + System::Action maxGroupTieredPackage, + System::Action scalableMatrixWithUnitPricing, + System::Action scalableMatrixWithTieredPricing, + System::Action cumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action newPlanMinimumComposite, + System::Action minimumComposite, System::Action percent, System::Action eventOutput ) { switch (this.Value) { - case NewPlanUnitPrice value: - newPlanUnit(value); + case Unit value: + unit(value); break; - case NewPlanTieredPrice value: - newPlanTiered(value); + case Tiered value: + tiered(value); break; - case NewPlanBulkPrice value: - newPlanBulk(value); + case Bulk value: + bulk(value); break; case BulkWithFilters value: bulkWithFilters(value); break; - case NewPlanPackagePrice value: - newPlanPackage(value); + case Package value: + package(value); break; - case NewPlanMatrixPrice value: - newPlanMatrix(value); + case Matrix value: + matrix(value); break; - case NewPlanThresholdTotalAmountPrice value: - newPlanThresholdTotalAmount(value); + case ThresholdTotalAmount value: + thresholdTotalAmount(value); break; - case NewPlanTieredPackagePrice value: - newPlanTieredPackage(value); + case TieredPackage value: + tieredPackage(value); break; - case NewPlanTieredWithMinimumPrice value: - newPlanTieredWithMinimum(value); + case TieredWithMinimum value: + tieredWithMinimum(value); break; - case NewPlanGroupedTieredPrice value: - newPlanGroupedTiered(value); + case GroupedTiered value: + groupedTiered(value); break; - case NewPlanTieredPackageWithMinimumPrice value: - newPlanTieredPackageWithMinimum(value); + case TieredPackageWithMinimum value: + tieredPackageWithMinimum(value); break; - case NewPlanPackageWithAllocationPrice value: - newPlanPackageWithAllocation(value); + case PackageWithAllocation value: + packageWithAllocation(value); break; - case NewPlanUnitWithPercentPrice value: - newPlanUnitWithPercent(value); + case UnitWithPercent value: + unitWithPercent(value); break; - case NewPlanMatrixWithAllocationPrice value: - newPlanMatrixWithAllocation(value); + case MatrixWithAllocation value: + matrixWithAllocation(value); break; case TieredWithProration value: tieredWithProration(value); break; - case NewPlanUnitWithProrationPrice value: - newPlanUnitWithProration(value); + case UnitWithProration value: + unitWithProration(value); break; - case NewPlanGroupedAllocationPrice value: - newPlanGroupedAllocation(value); + case GroupedAllocation value: + groupedAllocation(value); break; - case NewPlanBulkWithProrationPrice value: - newPlanBulkWithProration(value); + case BulkWithProration value: + bulkWithProration(value); break; - case NewPlanGroupedWithProratedMinimumPrice value: - newPlanGroupedWithProratedMinimum(value); + case GroupedWithProratedMinimum value: + groupedWithProratedMinimum(value); break; - case NewPlanGroupedWithMeteredMinimumPrice value: - newPlanGroupedWithMeteredMinimum(value); + case GroupedWithMeteredMinimum value: + groupedWithMeteredMinimum(value); break; case GroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; - case NewPlanMatrixWithDisplayNamePrice value: - newPlanMatrixWithDisplayName(value); + case MatrixWithDisplayName value: + matrixWithDisplayName(value); break; - case NewPlanGroupedTieredPackagePrice value: - newPlanGroupedTieredPackage(value); + case GroupedTieredPackage value: + groupedTieredPackage(value); break; - case NewPlanMaxGroupTieredPackagePrice value: - newPlanMaxGroupTieredPackage(value); + case MaxGroupTieredPackage value: + maxGroupTieredPackage(value); break; - case NewPlanScalableMatrixWithUnitPricingPrice value: - newPlanScalableMatrixWithUnitPricing(value); + case ScalableMatrixWithUnitPricing value: + scalableMatrixWithUnitPricing(value); break; - case NewPlanScalableMatrixWithTieredPricingPrice value: - newPlanScalableMatrixWithTieredPricing(value); + case ScalableMatrixWithTieredPricing value: + scalableMatrixWithTieredPricing(value); break; - case NewPlanCumulativeGroupedBulkPrice value: - newPlanCumulativeGroupedBulk(value); + case CumulativeGroupedBulk value: + cumulativeGroupedBulk(value); break; case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); + case MinimumComposite value: + minimumComposite(value); break; case Percent value: percent(value); @@ -2599,7 +2628,9 @@ public void Switch( eventOutput(value); break; default: - throw new OrbInvalidDataException("Data did not match any variant of Price"); + throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ); } } @@ -2618,35 +2649,35 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, + /// (Unit value) => {...}, + /// (Tiered value) => {...}, + /// (Bulk value) => {...}, /// (BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (Package value) => {...}, + /// (Matrix value) => {...}, + /// (ThresholdTotalAmount value) => {...}, + /// (TieredPackage value) => {...}, + /// (TieredWithMinimum value) => {...}, + /// (GroupedTiered value) => {...}, + /// (TieredPackageWithMinimum value) => {...}, + /// (PackageWithAllocation value) => {...}, + /// (UnitWithPercent value) => {...}, + /// (MatrixWithAllocation value) => {...}, /// (TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (UnitWithProration value) => {...}, + /// (GroupedAllocation value) => {...}, + /// (BulkWithProration value) => {...}, + /// (GroupedWithProratedMinimum value) => {...}, + /// (GroupedWithMeteredMinimum value) => {...}, /// (GroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (MatrixWithDisplayName value) => {...}, + /// (GroupedTieredPackage value) => {...}, + /// (MaxGroupTieredPackage value) => {...}, + /// (ScalableMatrixWithUnitPricing value) => {...}, + /// (ScalableMatrixWithTieredPricing value) => {...}, + /// (CumulativeGroupedBulk value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, + /// (MinimumComposite value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} /// ); @@ -2654,152 +2685,153 @@ public void Switch( /// /// public T Match( - System::Func newPlanUnit, - System::Func newPlanTiered, - System::Func newPlanBulk, + System::Func unit, + System::Func tiered, + System::Func bulk, 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 package, + System::Func matrix, + System::Func thresholdTotalAmount, + System::Func tieredPackage, + System::Func tieredWithMinimum, + System::Func groupedTiered, + System::Func tieredPackageWithMinimum, + System::Func packageWithAllocation, + System::Func unitWithPercent, + System::Func matrixWithAllocation, System::Func tieredWithProration, - System::Func newPlanUnitWithProration, - System::Func newPlanGroupedAllocation, - System::Func newPlanBulkWithProration, - System::Func newPlanGroupedWithProratedMinimum, - System::Func newPlanGroupedWithMeteredMinimum, + System::Func unitWithProration, + System::Func groupedAllocation, + System::Func bulkWithProration, + System::Func groupedWithProratedMinimum, + System::Func groupedWithMeteredMinimum, 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 matrixWithDisplayName, + System::Func groupedTieredPackage, + System::Func maxGroupTieredPackage, + System::Func scalableMatrixWithUnitPricing, + System::Func scalableMatrixWithTieredPricing, + System::Func cumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func newPlanMinimumComposite, + System::Func minimumComposite, System::Func percent, System::Func eventOutput ) { return this.Value switch { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), + Unit value => unit(value), + Tiered value => tiered(value), + Bulk value => bulk(value), BulkWithFilters 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), + Package value => package(value), + Matrix value => matrix(value), + ThresholdTotalAmount value => thresholdTotalAmount(value), + TieredPackage value => tieredPackage(value), + TieredWithMinimum value => tieredWithMinimum(value), + GroupedTiered value => groupedTiered(value), + TieredPackageWithMinimum value => tieredPackageWithMinimum(value), + PackageWithAllocation value => packageWithAllocation(value), + UnitWithPercent value => unitWithPercent(value), + MatrixWithAllocation value => matrixWithAllocation(value), TieredWithProration value => tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + UnitWithProration value => unitWithProration(value), + GroupedAllocation value => groupedAllocation(value), + BulkWithProration value => bulkWithProration(value), + GroupedWithProratedMinimum value => groupedWithProratedMinimum(value), + GroupedWithMeteredMinimum value => groupedWithMeteredMinimum(value), GroupedWithMinMaxThresholds 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), + MatrixWithDisplayName value => matrixWithDisplayName(value), + GroupedTieredPackage value => groupedTieredPackage(value), + MaxGroupTieredPackage value => maxGroupTieredPackage(value), + ScalableMatrixWithUnitPricing value => scalableMatrixWithUnitPricing(value), + ScalableMatrixWithTieredPricing value => scalableMatrixWithTieredPricing(value), + CumulativeGroupedBulk value => cumulativeGroupedBulk(value), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + MinimumComposite value => minimumComposite(value), Percent value => percent(value), EventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ), }; } - public static implicit operator Price(NewPlanUnitPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Unit value) => new(value); - public static implicit operator Price(NewPlanTieredPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Tiered value) => new(value); - public static implicit operator Price(NewPlanBulkPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Bulk value) => new(value); - public static implicit operator Price(BulkWithFilters value) => new(value); + public static implicit operator LicenseAllocationPrice(BulkWithFilters value) => new(value); - public static implicit operator Price(NewPlanPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Package value) => new(value); - public static implicit operator Price(NewPlanMatrixPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Matrix value) => new(value); - public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(ThresholdTotalAmount value) => + new(value); - public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackage value) => new(value); - public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithMinimum value) => new(value); - public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTiered value) => new(value); - public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackageWithMinimum value) => + new(value); - public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(PackageWithAllocation value) => + new(value); - public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithPercent value) => new(value); - public static implicit operator Price(NewPlanMatrixWithAllocationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MatrixWithAllocation value) => + new(value); - public static implicit operator Price(TieredWithProration value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithProration value) => new(value); - public static implicit operator Price(NewPlanUnitWithProrationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithProration value) => new(value); - public static implicit operator Price(NewPlanGroupedAllocationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedAllocation value) => new(value); - public static implicit operator Price(NewPlanBulkWithProrationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(BulkWithProration value) => new(value); - public static implicit operator Price(NewPlanGroupedWithProratedMinimumPrice value) => + public static implicit operator LicenseAllocationPrice(GroupedWithProratedMinimum value) => new(value); - public static implicit operator Price(NewPlanGroupedWithMeteredMinimumPrice value) => + public static implicit operator LicenseAllocationPrice(GroupedWithMeteredMinimum value) => new(value); - public static implicit operator Price(GroupedWithMinMaxThresholds value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedWithMinMaxThresholds value) => + new(value); - public static implicit operator Price(NewPlanMatrixWithDisplayNamePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MatrixWithDisplayName value) => + new(value); - public static implicit operator Price(NewPlanGroupedTieredPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTieredPackage value) => + new(value); - public static implicit operator Price(NewPlanMaxGroupTieredPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MaxGroupTieredPackage value) => + new(value); - public static implicit operator Price(NewPlanScalableMatrixWithUnitPricingPrice value) => + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithUnitPricing value) => new(value); - public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPrice value) => + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithTieredPricing value) => new(value); - public static implicit operator Price(NewPlanCumulativeGroupedBulkPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(CumulativeGroupedBulk value) => + new(value); - public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); + public static implicit operator LicenseAllocationPrice(CumulativeGroupedAllocation value) => + new(value); - public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MinimumComposite value) => new(value); - public static implicit operator Price(Percent value) => new(value); + public static implicit operator LicenseAllocationPrice(Percent value) => new(value); - public static implicit operator Price(EventOutput value) => new(value); + public static implicit operator LicenseAllocationPrice(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2815,46 +2847,46 @@ public override void Validate() { if (this.Value == null) { - throw new OrbInvalidDataException("Data did not match any variant of Price"); + throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ); } this.Switch( - (newPlanUnit) => newPlanUnit.Validate(), - (newPlanTiered) => newPlanTiered.Validate(), - (newPlanBulk) => newPlanBulk.Validate(), + (unit) => unit.Validate(), + (tiered) => tiered.Validate(), + (bulk) => bulk.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(), + (package) => package.Validate(), + (matrix) => matrix.Validate(), + (thresholdTotalAmount) => thresholdTotalAmount.Validate(), + (tieredPackage) => tieredPackage.Validate(), + (tieredWithMinimum) => tieredWithMinimum.Validate(), + (groupedTiered) => groupedTiered.Validate(), + (tieredPackageWithMinimum) => tieredPackageWithMinimum.Validate(), + (packageWithAllocation) => packageWithAllocation.Validate(), + (unitWithPercent) => unitWithPercent.Validate(), + (matrixWithAllocation) => matrixWithAllocation.Validate(), (tieredWithProration) => tieredWithProration.Validate(), - (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), - (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), - (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), - (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), - (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), + (unitWithProration) => unitWithProration.Validate(), + (groupedAllocation) => groupedAllocation.Validate(), + (bulkWithProration) => bulkWithProration.Validate(), + (groupedWithProratedMinimum) => groupedWithProratedMinimum.Validate(), + (groupedWithMeteredMinimum) => groupedWithMeteredMinimum.Validate(), (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), - (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), - (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), - (newPlanScalableMatrixWithUnitPricing) => - newPlanScalableMatrixWithUnitPricing.Validate(), - (newPlanScalableMatrixWithTieredPricing) => - newPlanScalableMatrixWithTieredPricing.Validate(), - (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), + (matrixWithDisplayName) => matrixWithDisplayName.Validate(), + (groupedTieredPackage) => groupedTieredPackage.Validate(), + (maxGroupTieredPackage) => maxGroupTieredPackage.Validate(), + (scalableMatrixWithUnitPricing) => scalableMatrixWithUnitPricing.Validate(), + (scalableMatrixWithTieredPricing) => scalableMatrixWithTieredPricing.Validate(), + (cumulativeGroupedBulk) => cumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (minimumComposite) => minimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(Price? other) => + public virtual bool Equals(LicenseAllocationPrice? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -2874,35 +2906,35 @@ int VariantIndex() { return this.Value switch { - NewPlanUnitPrice _ => 0, - NewPlanTieredPrice _ => 1, - NewPlanBulkPrice _ => 2, + Unit _ => 0, + Tiered _ => 1, + Bulk _ => 2, BulkWithFilters _ => 3, - NewPlanPackagePrice _ => 4, - NewPlanMatrixPrice _ => 5, - NewPlanThresholdTotalAmountPrice _ => 6, - NewPlanTieredPackagePrice _ => 7, - NewPlanTieredWithMinimumPrice _ => 8, - NewPlanGroupedTieredPrice _ => 9, - NewPlanTieredPackageWithMinimumPrice _ => 10, - NewPlanPackageWithAllocationPrice _ => 11, - NewPlanUnitWithPercentPrice _ => 12, - NewPlanMatrixWithAllocationPrice _ => 13, + Package _ => 4, + Matrix _ => 5, + ThresholdTotalAmount _ => 6, + TieredPackage _ => 7, + TieredWithMinimum _ => 8, + GroupedTiered _ => 9, + TieredPackageWithMinimum _ => 10, + PackageWithAllocation _ => 11, + UnitWithPercent _ => 12, + MatrixWithAllocation _ => 13, TieredWithProration _ => 14, - NewPlanUnitWithProrationPrice _ => 15, - NewPlanGroupedAllocationPrice _ => 16, - NewPlanBulkWithProrationPrice _ => 17, - NewPlanGroupedWithProratedMinimumPrice _ => 18, - NewPlanGroupedWithMeteredMinimumPrice _ => 19, + UnitWithProration _ => 15, + GroupedAllocation _ => 16, + BulkWithProration _ => 17, + GroupedWithProratedMinimum _ => 18, + GroupedWithMeteredMinimum _ => 19, GroupedWithMinMaxThresholds _ => 20, - NewPlanMatrixWithDisplayNamePrice _ => 21, - NewPlanGroupedTieredPackagePrice _ => 22, - NewPlanMaxGroupTieredPackagePrice _ => 23, - NewPlanScalableMatrixWithUnitPricingPrice _ => 24, - NewPlanScalableMatrixWithTieredPricingPrice _ => 25, - NewPlanCumulativeGroupedBulkPrice _ => 26, + MatrixWithDisplayName _ => 21, + GroupedTieredPackage _ => 22, + MaxGroupTieredPackage _ => 23, + ScalableMatrixWithUnitPricing _ => 24, + ScalableMatrixWithTieredPricing _ => 25, + CumulativeGroupedBulk _ => 26, CumulativeGroupedAllocation _ => 27, - NewPlanMinimumCompositePrice _ => 28, + MinimumComposite _ => 28, Percent _ => 29, EventOutput _ => 30, _ => -1, @@ -2910,9 +2942,9 @@ int VariantIndex() } } -sealed class PriceConverter : JsonConverter +sealed class LicenseAllocationPriceConverter : JsonConverter { - public override Price? Read( + public override LicenseAllocationPrice? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2935,10 +2967,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2957,10 +2986,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2979,10 +3005,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3023,10 +3046,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3045,10 +3065,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3067,7 +3084,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3089,10 +3106,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3111,7 +3125,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3133,10 +3147,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3155,11 +3166,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3178,11 +3188,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3201,7 +3210,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3223,7 +3232,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3267,7 +3276,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3289,7 +3298,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3311,7 +3320,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3333,11 +3342,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3356,11 +3364,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3401,11 +3408,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3424,7 +3430,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3446,11 +3452,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3469,11 +3474,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3492,11 +3496,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3515,11 +3518,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3560,7 +3562,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3618,57 +3620,71 @@ JsonSerializerOptions options } default: { - return new Price(element); + return new LicenseAllocationPrice(element); } } } - public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + LicenseAllocationPrice? value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize(writer, value?.Json, options); } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class BulkWithFilters : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Unit : JsonModel { /// - /// Configuration for bulk_with_filters pricing + /// The cadence to bill for this price on. /// - public required BulkWithFiltersConfig BulkWithFiltersConfig + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("bulk_with_filters_config"); + return this._rawData.GetNotNullClass>("cadence"); } - init { this._rawData.Set("bulk_with_filters_config", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The cadence to bill for this price on. + /// The id of the item the price will be associated with. /// - public required ApiEnum Cadence + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public required string ItemID + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("item_id", value); } } /// @@ -3697,6 +3713,19 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for unit pricing + /// + public required UnitConfig UnitConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_config"); + } + init { this._rawData.Set("unit_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -3901,19 +3930,18 @@ public string? ReferenceID /// public override void Validate() { - this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") - ) - ) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("unit"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.UnitConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -3930,349 +3958,186 @@ public override void Validate() _ = this.ReferenceID; } - public BulkWithFilters() + public Unit() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("unit"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public BulkWithFilters(BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } + public Unit(Unit unit) + : base(unit) { } #pragma warning restore CS8618 - public BulkWithFilters(IReadOnlyDictionary rawData) + public Unit(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("unit"); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFilters(FrozenDictionary rawData) + Unit(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Unit FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class UnitFromRaw : IFromRawJson { /// - public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => - BulkWithFilters.FromRawUnchecked(rawData); + public Unit FromRawUnchecked(IReadOnlyDictionary rawData) => + Unit.FromRawUnchecked(rawData); } /// -/// Configuration for bulk_with_filters pricing +/// The cadence to bill for this price on. /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class BulkWithFiltersConfig : JsonModel +[JsonConverter(typeof(CadenceConverter))] +public enum Cadence { - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>("filters"); - } - init - { - this._rawData.Set>( - "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>("tiers"); - } - init - { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); - } - } + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - /// - public override void Validate() +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) + return JsonSerializer.Deserialize(ref reader, options) switch { - item.Validate(); - } - } - - public BulkWithFiltersConfig() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) - : base(bulkWithFiltersConfig) { } -#pragma warning restore CS8618 - - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), + }; } -#pragma warning restore CS8618 - /// - public static BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); } } -class BulkWithFiltersConfigFromRaw : IFromRawJson -{ - /// - public BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Filter : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseAllocation : JsonModel { /// - /// Event property key to filter on + /// The amount of credits granted per active license per cadence. /// - public required string PropertyKey + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("property_key", value); } + init { this._rawData.Set("amount", value); } } /// - /// Event property value to match + /// The currency of the license allocation. /// - public required string PropertyValue + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } - - public Filter() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public Filter(Filter filter) - : base(filter) { } -#pragma warning restore CS8618 - - public Filter(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Filter(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class FilterFromRaw : IFromRawJson -{ - /// - public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => - Filter.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Tier : 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); } + init { this._rawData.Set("currency", value); } } /// - /// The lower bound for this tier + /// When True, overage beyond the allocation is written off. /// - public string? TierLowerBound + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.UnitAmount; - _ = this.TierLowerBound; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public Tier() { } + public LicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public Tier(Tier tier) - : base(tier) { } + public LicenseAllocation(LicenseAllocation licenseAllocation) + : base(licenseAllocation) { } #pragma warning restore CS8618 - public Tier(IReadOnlyDictionary rawData) + public LicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Tier(FrozenDictionary rawData) + LicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static LicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class TierFromRaw : IFromRawJson +class LicenseAllocationFromRaw : IFromRawJson { /// - public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => - Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "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, Cadence value, JsonSerializerOptions options) - { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); - } + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); } [JsonConverter(typeof(ConversionRateConfigConverter))] @@ -4564,20 +4429,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class TieredWithProration : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Tiered : 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); } } @@ -4595,6 +4458,29 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The pricing model type /// @@ -4622,18 +4508,16 @@ public required string Name } /// - /// Configuration for tiered_with_proration pricing + /// Configuration for tiered pricing /// - public required TieredWithProrationConfig TieredWithProrationConfig + public required TieredConfig TieredConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); + return this._rawData.GetNotNullClass("tiered_config"); } - init { this._rawData.Set("tiered_with_proration_config", value); } + init { this._rawData.Set("tiered_config", value); } } /// @@ -4695,12 +4579,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public TieredWithProrationConversionRateConfig? ConversionRateConfig + public TieredConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4844,17 +4728,16 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") - ) - ) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("tiered"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); + this.TieredConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -4871,53 +4754,51 @@ public override void Validate() _ = this.ReferenceID; } - public TieredWithProration() + public Tiered() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("tiered"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public TieredWithProration(TieredWithProration tieredWithProration) - : base(tieredWithProration) { } + public Tiered(Tiered tiered) + : base(tiered) { } #pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public Tiered(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("tiered"); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + Tiered(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tiered FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationFromRaw : IFromRawJson +class TieredFromRaw : IFromRawJson { /// - public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => - TieredWithProration.FromRawUnchecked(rawData); + public Tiered FromRawUnchecked(IReadOnlyDictionary rawData) => + Tiered.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(TieredCadenceConverter))] +public enum TieredCadence { Annual, SemiAnnual, @@ -4927,9 +4808,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter : JsonConverter +sealed class TieredCadenceConverter : JsonConverter { - public override TieredWithProrationCadence Read( + public override TieredCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4937,19 +4818,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => TieredWithProrationCadence.Annual, - "semi_annual" => TieredWithProrationCadence.SemiAnnual, - "monthly" => TieredWithProrationCadence.Monthly, - "quarterly" => TieredWithProrationCadence.Quarterly, - "one_time" => TieredWithProrationCadence.OneTime, - "custom" => TieredWithProrationCadence.Custom, - _ => (TieredWithProrationCadence)(-1), + "annual" => TieredCadence.Annual, + "semi_annual" => TieredCadence.SemiAnnual, + "monthly" => TieredCadence.Monthly, + "quarterly" => TieredCadence.Quarterly, + "one_time" => TieredCadence.OneTime, + "custom" => TieredCadence.Custom, + _ => (TieredCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - TieredWithProrationCadence value, + TieredCadence value, JsonSerializerOptions options ) { @@ -4957,12 +4838,12 @@ JsonSerializerOptions options writer, value switch { - TieredWithProrationCadence.Annual => "annual", - TieredWithProrationCadence.SemiAnnual => "semi_annual", - TieredWithProrationCadence.Monthly => "monthly", - TieredWithProrationCadence.Quarterly => "quarterly", - TieredWithProrationCadence.OneTime => "one_time", - TieredWithProrationCadence.Custom => "custom", + TieredCadence.Annual => "annual", + TieredCadence.SemiAnnual => "semi_annual", + TieredCadence.Monthly => "monthly", + TieredCadence.Quarterly => "quarterly", + TieredCadence.OneTime => "one_time", + TieredCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4972,156 +4853,79 @@ JsonSerializerOptions options } } -/// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class TieredWithProrationConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredLicenseAllocation : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// The amount of credits granted per active license per cadence. /// - public required IReadOnlyList Tiers + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); + return this._rawData.GetNotNullClass("amount"); } - init - { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public TieredWithProrationConfig() { } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) - : base(tieredWithProrationConfig) { } -#pragma warning restore CS8618 - - public TieredWithProrationConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + init { this._rawData.Set("amount", value); } } - [SetsRequiredMembers] - public TieredWithProrationConfig(IReadOnlyList tiers) - : this() - { - this.Tiers = tiers; - } -} - -class TieredWithProrationConfigFromRaw : IFromRawJson -{ - /// - public TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => TieredWithProrationConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single tiered with proration tier -/// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class TieredWithProrationConfigTier : JsonModel -{ /// - /// Inclusive tier starting value + /// The currency of the license allocation. /// - public required string TierLowerBound + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("currency", value); } } /// - /// Amount per unit + /// When True, overage beyond the allocation is written off. /// - public required string UnitAmount + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.TierLowerBound; - _ = this.UnitAmount; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public TieredWithProrationConfigTier() { } + public TieredLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public TieredWithProrationConfigTier( - TieredWithProrationConfigTier tieredWithProrationConfigTier - ) - : base(tieredWithProrationConfigTier) { } + public TieredLicenseAllocation(TieredLicenseAllocation tieredLicenseAllocation) + : base(tieredLicenseAllocation) { } #pragma warning restore CS8618 - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + public TieredLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfigTier(FrozenDictionary rawData) + TieredLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5129,16 +4933,16 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw : IFromRawJson +class TieredLicenseAllocationFromRaw : IFromRawJson { /// - public TieredWithProrationConfigTier FromRawUnchecked( + public TieredLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => TieredLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(TieredConversionRateConfigConverter))] +public record class TieredConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5155,7 +4959,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5164,7 +4968,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5173,7 +4977,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public TieredConversionRateConfig(JsonElement element) { this._element = element; } @@ -5255,7 +5059,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of TieredConversionRateConfig" ); } } @@ -5291,16 +5095,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of TieredConversionRateConfig" ), }; } - public static implicit operator TieredWithProrationConversionRateConfig( + public static implicit operator TieredConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator TieredWithProrationConversionRateConfig( + public static implicit operator TieredConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5319,13 +5123,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of TieredConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + public virtual bool Equals(TieredConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -5352,10 +5156,9 @@ int VariantIndex() } } -sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class TieredConversionRateConfigConverter : JsonConverter { - public override TieredWithProrationConversionRateConfig? Read( + public override TieredConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5420,14 +5223,14 @@ JsonSerializerOptions options } default: { - return new TieredWithProrationConversionRateConfig(element); + return new TieredConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - TieredWithProrationConversionRateConfig value, + TieredConversionRateConfig value, JsonSerializerOptions options ) { @@ -5435,39 +5238,33 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Bulk : JsonModel { /// - /// The cadence to bill for this price on. + /// Configuration for bulk pricing /// - public required ApiEnum Cadence + public required BulkConfig BulkConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass("bulk_config"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("bulk_config", value); } } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// The cadence to bill for this price on. /// - public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNotNullClass>("cadence"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("cadence", value); } } /// @@ -5483,6 +5280,29 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The pricing model type /// @@ -5568,12 +5388,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public BulkConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5715,15 +5535,14 @@ public string? ReferenceID /// public override void Validate() { + this.BulkConfig.Validate(); this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") - ) - ) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("bulk"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -5744,54 +5563,51 @@ public override void Validate() _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public Bulk() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("bulk"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) - : base(groupedWithMinMaxThresholds) { } + public Bulk(Bulk bulk) + : base(bulk) { } #pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public Bulk(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("bulk"); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + Bulk(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Bulk FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson +class BulkFromRaw : IFromRawJson { /// - public GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + public Bulk FromRawUnchecked(IReadOnlyDictionary rawData) => + Bulk.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(BulkCadenceConverter))] +public enum BulkCadence { Annual, SemiAnnual, @@ -5801,10 +5617,9 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class BulkCadenceConverter : JsonConverter { - public override GroupedWithMinMaxThresholdsCadence Read( + public override BulkCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5812,19 +5627,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, - "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => GroupedWithMinMaxThresholdsCadence.Custom, - _ => (GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => BulkCadence.Annual, + "semi_annual" => BulkCadence.SemiAnnual, + "monthly" => BulkCadence.Monthly, + "quarterly" => BulkCadence.Quarterly, + "one_time" => BulkCadence.OneTime, + "custom" => BulkCadence.Custom, + _ => (BulkCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCadence value, + BulkCadence value, JsonSerializerOptions options ) { @@ -5832,12 +5647,12 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMinMaxThresholdsCadence.Annual => "annual", - GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - GroupedWithMinMaxThresholdsCadence.Custom => "custom", + BulkCadence.Annual => "annual", + BulkCadence.SemiAnnual => "semi_annual", + BulkCadence.Monthly => "monthly", + BulkCadence.Quarterly => "quarterly", + BulkCadence.OneTime => "one_time", + BulkCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5847,103 +5662,79 @@ JsonSerializerOptions options } } -/// -/// Configuration for grouped_with_min_max_thresholds pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - GroupedWithMinMaxThresholdsConfig, - GroupedWithMinMaxThresholdsConfigFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkLicenseAllocation : 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 + /// The amount of credits granted per active license per cadence. /// - public required string MaximumCharge + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("amount", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The currency of the license allocation. /// - public required string MinimumCharge + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("currency", value); } } /// - /// The base price charged per group + /// When True, overage beyond the allocation is written off. /// - public required string PerUnitRate + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public GroupedWithMinMaxThresholdsConfig() { } + public BulkLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public GroupedWithMinMaxThresholdsConfig( - GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } + public BulkLicenseAllocation(BulkLicenseAllocation bulkLicenseAllocation) + : base(bulkLicenseAllocation) { } #pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public BulkLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + BulkLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static BulkLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5951,16 +5742,16 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson +class BulkLicenseAllocationFromRaw : IFromRawJson { /// - public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public BulkLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => BulkLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkConversionRateConfigConverter))] +public record class BulkConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5977,7 +5768,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5986,7 +5777,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5995,7 +5786,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public BulkConversionRateConfig(JsonElement element) { this._element = element; } @@ -6077,7 +5868,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of BulkConversionRateConfig" ); } } @@ -6113,16 +5904,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of BulkConversionRateConfig" ), }; } - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator BulkConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator BulkConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6141,13 +5932,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of BulkConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + public virtual bool Equals(BulkConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -6174,10 +5965,9 @@ int VariantIndex() } } -sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class BulkConversionRateConfigConverter : JsonConverter { - public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override BulkConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6242,14 +6032,14 @@ JsonSerializerOptions options } default: { - return new GroupedWithMinMaxThresholdsConversionRateConfig(element); + return new BulkConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsConversionRateConfig value, + BulkConversionRateConfig value, JsonSerializerOptions options ) { @@ -6257,39 +6047,35 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class CumulativeGroupedAllocation : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFilters : JsonModel { /// - /// The cadence to bill for this price on. + /// Configuration for bulk_with_filters pricing /// - public required ApiEnum Cadence + public required BulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass("bulk_with_filters_config"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("bulk_with_filters_config", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// The cadence to bill for this price on. /// - public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass>( + "cadence" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("cadence", value); } } /// @@ -6305,6 +6091,29 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The pricing model type /// @@ -6390,12 +6199,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public BulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6537,13 +6346,17 @@ public string? ReferenceID /// public override void Validate() { + this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("bulk_with_filters") ) ) { @@ -6566,34 +6379,126 @@ public override void Validate() _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public BulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) - : base(cumulativeGroupedAllocation) { } + public BulkWithFilters(BulkWithFilters bulkWithFilters) + : base(bulkWithFilters) { } #pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public BulkWithFilters(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + BulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocation FromRawUnchecked( + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithFiltersFromRaw : IFromRawJson +{ + /// + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("filters"); + } + init + { + this._rawData.Set>( + "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>("tiers"); + } + init + { + this._rawData.Set>( + "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 BulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) + : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public BulkWithFiltersConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithFiltersConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6601,19 +6506,174 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public CumulativeGroupedAllocation FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Filter : 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 Filter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) + : base(filter) { } +#pragma warning restore CS8618 + + public Filter(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Filter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FilterFromRaw : IFromRawJson +{ + /// + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Tier : 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 Tier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Tier(Tier tier) + : base(tier) { } +#pragma warning restore CS8618 + + public Tier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Tier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Tier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class TierFromRaw : IFromRawJson +{ + /// + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(BulkWithFiltersCadenceConverter))] +public enum BulkWithFiltersCadence { Annual, SemiAnnual, @@ -6623,10 +6683,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class BulkWithFiltersCadenceConverter : JsonConverter { - public override CumulativeGroupedAllocationCadence Read( + public override BulkWithFiltersCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6634,19 +6693,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, - "one_time" => CumulativeGroupedAllocationCadence.OneTime, - "custom" => CumulativeGroupedAllocationCadence.Custom, - _ => (CumulativeGroupedAllocationCadence)(-1), + "annual" => BulkWithFiltersCadence.Annual, + "semi_annual" => BulkWithFiltersCadence.SemiAnnual, + "monthly" => BulkWithFiltersCadence.Monthly, + "quarterly" => BulkWithFiltersCadence.Quarterly, + "one_time" => BulkWithFiltersCadence.OneTime, + "custom" => BulkWithFiltersCadence.Custom, + _ => (BulkWithFiltersCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCadence value, + BulkWithFiltersCadence value, JsonSerializerOptions options ) { @@ -6654,12 +6713,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCadence.Annual => "annual", - CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - CumulativeGroupedAllocationCadence.Monthly => "monthly", - CumulativeGroupedAllocationCadence.Quarterly => "quarterly", - CumulativeGroupedAllocationCadence.OneTime => "one_time", - CumulativeGroupedAllocationCadence.Custom => "custom", + BulkWithFiltersCadence.Annual => "annual", + BulkWithFiltersCadence.SemiAnnual => "semi_annual", + BulkWithFiltersCadence.Monthly => "monthly", + BulkWithFiltersCadence.Quarterly => "quarterly", + BulkWithFiltersCadence.OneTime => "one_time", + BulkWithFiltersCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6669,103 +6728,86 @@ JsonSerializerOptions options } } -/// -/// Configuration for cumulative_grouped_allocation pricing -/// [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedAllocationConfig, - CumulativeGroupedAllocationConfigFromRaw + BulkWithFiltersLicenseAllocation, + BulkWithFiltersLicenseAllocationFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class BulkWithFiltersLicenseAllocation : JsonModel { /// - /// The overall allocation across all groups + /// The amount of credits granted per active license per cadence. /// - public required string CumulativeAllocation + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("amount", value); } } /// - /// The allocation per individual group + /// The currency of the license allocation. /// - public required string GroupAllocation + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("currency", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// When True, overage beyond the allocation is written off. /// - public required string UnitAmount + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public CumulativeGroupedAllocationConfig() { } + public BulkWithFiltersLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public CumulativeGroupedAllocationConfig( - CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + public BulkWithFiltersLicenseAllocation( + BulkWithFiltersLicenseAllocation bulkWithFiltersLicenseAllocation ) - : base(cumulativeGroupedAllocationConfig) { } + : base(bulkWithFiltersLicenseAllocation) { } #pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public BulkWithFiltersLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + BulkWithFiltersLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static BulkWithFiltersLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6773,16 +6815,16 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +class BulkWithFiltersLicenseAllocationFromRaw : IFromRawJson { /// - public CumulativeGroupedAllocationConfig FromRawUnchecked( + public BulkWithFiltersLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkWithFiltersConversionRateConfigConverter))] +public record class BulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6799,7 +6841,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6808,7 +6850,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6817,7 +6859,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public BulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -6899,7 +6941,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of BulkWithFiltersConversionRateConfig" ); } } @@ -6935,16 +6977,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 BulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6963,13 +7005,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 BulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + public virtual bool Equals(BulkWithFiltersConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -6996,10 +7038,10 @@ int VariantIndex() } } -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class BulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override CumulativeGroupedAllocationConversionRateConfig? Read( + public override BulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7064,14 +7106,14 @@ JsonSerializerOptions options } default: { - return new CumulativeGroupedAllocationConversionRateConfig(element); + return new BulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationConversionRateConfig value, + BulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -7079,18 +7121,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Package : 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); } } @@ -7108,6 +7150,29 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The pricing model type /// @@ -7135,16 +7200,16 @@ public required string Name } /// - /// Configuration for percent pricing + /// Configuration for package pricing /// - public required PercentConfig PercentConfig + public required PackageConfig PackageConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("percent_config"); + return this._rawData.GetNotNullClass("package_config"); } - init { this._rawData.Set("percent_config", value); } + init { this._rawData.Set("package_config", value); } } /// @@ -7206,12 +7271,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PercentConversionRateConfig? ConversionRateConfig + public PackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7355,12 +7420,16 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("package"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); + this.PackageConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -7377,51 +7446,51 @@ public override void Validate() _ = this.ReferenceID; } - public Percent() + public Package() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("package"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public Percent(Percent percent) - : base(percent) { } + public Package(Package package) + : base(package) { } #pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public Package(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("package"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + Package(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Package FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PackageFromRaw : IFromRawJson { /// - public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => - Percent.FromRawUnchecked(rawData); + public Package FromRawUnchecked(IReadOnlyDictionary rawData) => + Package.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(PackageCadenceConverter))] +public enum PackageCadence { Annual, SemiAnnual, @@ -7431,9 +7500,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class PackageCadenceConverter : JsonConverter { - public override PercentCadence Read( + public override PackageCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7441,19 +7510,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PercentCadence.Annual, - "semi_annual" => PercentCadence.SemiAnnual, - "monthly" => PercentCadence.Monthly, - "quarterly" => PercentCadence.Quarterly, - "one_time" => PercentCadence.OneTime, - "custom" => PercentCadence.Custom, - _ => (PercentCadence)(-1), + "annual" => PackageCadence.Annual, + "semi_annual" => PackageCadence.SemiAnnual, + "monthly" => PackageCadence.Monthly, + "quarterly" => PackageCadence.Quarterly, + "one_time" => PackageCadence.OneTime, + "custom" => PackageCadence.Custom, + _ => (PackageCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PercentCadence value, + PackageCadence value, JsonSerializerOptions options ) { @@ -7461,12 +7530,12 @@ JsonSerializerOptions options writer, value switch { - PercentCadence.Annual => "annual", - PercentCadence.SemiAnnual => "semi_annual", - PercentCadence.Monthly => "monthly", - PercentCadence.Quarterly => "quarterly", - PercentCadence.OneTime => "one_time", - PercentCadence.Custom => "custom", + PackageCadence.Annual => "annual", + PackageCadence.SemiAnnual => "semi_annual", + PackageCadence.Monthly => "monthly", + PackageCadence.Quarterly => "quarterly", + PackageCadence.OneTime => "one_time", + PackageCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7476,75 +7545,98 @@ JsonSerializerOptions options } } -/// -/// Configuration for percent pricing -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PercentConfig : JsonModel +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PackageLicenseAllocation : JsonModel { /// - /// What percent of the component subtotals to charge + /// The amount of credits granted per active license per cadence. /// - public required double Percent + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public PercentConfig() { } + public PackageLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public PercentConfig(PercentConfig percentConfig) - : base(percentConfig) { } + public PackageLicenseAllocation(PackageLicenseAllocation packageLicenseAllocation) + : base(packageLicenseAllocation) { } #pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public PackageLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + PackageLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static PackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class PackageLicenseAllocationFromRaw : IFromRawJson { /// - public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - PercentConfig.FromRawUnchecked(rawData); + public PackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(PackageConversionRateConfigConverter))] +public record class PackageConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7561,7 +7653,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public PackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7570,7 +7662,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public PackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7579,7 +7671,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public PackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -7661,7 +7753,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of PackageConversionRateConfig" ); } } @@ -7697,16 +7789,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 PackageConversionRateConfig" ), }; } - public static implicit operator PercentConversionRateConfig( + public static implicit operator PackageConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PercentConversionRateConfig( + public static implicit operator PackageConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7725,13 +7817,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 PackageConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) => + public virtual bool Equals(PackageConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -7758,9 +7850,9 @@ int VariantIndex() } } -sealed class PercentConversionRateConfigConverter : JsonConverter +sealed class PackageConversionRateConfigConverter : JsonConverter { - public override PercentConversionRateConfig? Read( + public override PackageConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7825,14 +7917,14 @@ JsonSerializerOptions options } default: { - return new PercentConversionRateConfig(element); + return new PackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PercentConversionRateConfig value, + PackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -7840,46 +7932,69 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutput : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Matrix : 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); } } /// - /// Configuration for event_output pricing + /// The id of the item the price will be associated with. /// - public required EventOutputConfig EventOutputConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("event_output_config"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("event_output_config", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public required string ItemID + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("item_id", value); } + } + + /// + /// Configuration for matrix pricing + /// + public required MatrixConfig MatrixConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("matrix_config"); + } + init { this._rawData.Set("matrix_config", value); } } /// @@ -7967,12 +8082,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public EventOutputConversionRateConfig? ConversionRateConfig + public MatrixConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8115,14 +8230,13 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixConfig.Validate(); + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("matrix"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -8143,51 +8257,51 @@ public override void Validate() _ = this.ReferenceID; } - public EventOutput() + public Matrix() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("matrix"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public EventOutput(EventOutput eventOutput) - : base(eventOutput) { } + public Matrix(Matrix matrix) + : base(matrix) { } #pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public Matrix(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("matrix"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + Matrix(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static Matrix FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputFromRaw : IFromRawJson +class MatrixFromRaw : IFromRawJson { /// - public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutput.FromRawUnchecked(rawData); + public Matrix FromRawUnchecked(IReadOnlyDictionary rawData) => + Matrix.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(MatrixCadenceConverter))] +public enum MatrixCadence { Annual, SemiAnnual, @@ -8197,9 +8311,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter : JsonConverter +sealed class MatrixCadenceConverter : JsonConverter { - public override EventOutputCadence Read( + public override MatrixCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8207,19 +8321,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => EventOutputCadence.Annual, - "semi_annual" => EventOutputCadence.SemiAnnual, - "monthly" => EventOutputCadence.Monthly, - "quarterly" => EventOutputCadence.Quarterly, - "one_time" => EventOutputCadence.OneTime, - "custom" => EventOutputCadence.Custom, - _ => (EventOutputCadence)(-1), + "annual" => MatrixCadence.Annual, + "semi_annual" => MatrixCadence.SemiAnnual, + "monthly" => MatrixCadence.Monthly, + "quarterly" => MatrixCadence.Quarterly, + "one_time" => MatrixCadence.OneTime, + "custom" => MatrixCadence.Custom, + _ => (MatrixCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - EventOutputCadence value, + MatrixCadence value, JsonSerializerOptions options ) { @@ -8227,12 +8341,12 @@ JsonSerializerOptions options writer, value switch { - EventOutputCadence.Annual => "annual", - EventOutputCadence.SemiAnnual => "semi_annual", - EventOutputCadence.Monthly => "monthly", - EventOutputCadence.Quarterly => "quarterly", - EventOutputCadence.OneTime => "one_time", - EventOutputCadence.Custom => "custom", + MatrixCadence.Annual => "annual", + MatrixCadence.SemiAnnual => "semi_annual", + MatrixCadence.Monthly => "monthly", + MatrixCadence.Quarterly => "quarterly", + MatrixCadence.OneTime => "one_time", + MatrixCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8242,108 +8356,96 @@ JsonSerializerOptions options } } -/// -/// Configuration for event_output pricing -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutputConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixLicenseAllocation : JsonModel { /// - /// The key in the event data to extract the unit rate from. + /// The amount of credits granted per active license per cadence. /// - public required string UnitRatingKey + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("unit_rating_key", value); } + init { this._rawData.Set("amount", 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. + /// The currency of the license allocation. /// - public string? DefaultUnitRate + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("default_unit_rate", value); } + init { this._rawData.Set("currency", 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. + /// When True, overage beyond the allocation is written off. /// - public string? GroupingKey + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public EventOutputConfig() { } + public MatrixLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public EventOutputConfig(EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } + public MatrixLicenseAllocation(MatrixLicenseAllocation matrixLicenseAllocation) + : base(matrixLicenseAllocation) { } #pragma warning restore CS8618 - public EventOutputConfig(IReadOnlyDictionary rawData) + public MatrixLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + MatrixLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static EventOutputConfig FromRawUnchecked( + /// + public static MatrixLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() - { - this.UnitRatingKey = unitRatingKey; - } } -class EventOutputConfigFromRaw : IFromRawJson +class MatrixLicenseAllocationFromRaw : IFromRawJson { /// - public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutputConfig.FromRawUnchecked(rawData); + public MatrixLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase +[JsonConverter(typeof(MatrixConversionRateConfigConverter))] +public record class MatrixConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8360,7 +8462,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public MatrixConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8369,7 +8471,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public MatrixConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8378,7 +8480,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public MatrixConversionRateConfig(JsonElement element) { this._element = element; } @@ -8460,7 +8562,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of MatrixConversionRateConfig" ); } } @@ -8496,16 +8598,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of MatrixConversionRateConfig" ), }; } - public static implicit operator EventOutputConversionRateConfig( + public static implicit operator MatrixConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator EventOutputConversionRateConfig( + public static implicit operator MatrixConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8524,13 +8626,13 @@ 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 MatrixConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) => + public virtual bool Equals(MatrixConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -8557,10 +8659,9 @@ int VariantIndex() } } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class MatrixConversionRateConfigConverter : JsonConverter { - public override EventOutputConversionRateConfig? Read( + public override MatrixConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8625,14 +8726,14 @@ JsonSerializerOptions options } default: { - return new EventOutputConversionRateConfig(element); + return new MatrixConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - EventOutputConversionRateConfig value, + MatrixConversionRateConfig value, JsonSerializerOptions options ) { @@ -8640,237 +8741,522 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdTotalAmount : JsonModel { /// - /// The id of the adjustment to remove from on the plan. + /// The cadence to bill for this price on. /// - public required string AdjustmentID + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } - init { this._rawData.Set("adjustment_id", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The phase to remove this adjustment from. + /// The id of the item the price will be associated with. /// - public long? PlanPhaseOrder + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("item_id", value); } } - /// - public override void Validate() + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations { - _ = this.AdjustmentID; - _ = this.PlanPhaseOrder; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } } - public RemoveAdjustment() { } + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } -#pragma warning restore CS8618 + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } - public RemoveAdjustment(IReadOnlyDictionary rawData) + /// + /// Configuration for threshold_total_amount pricing + /// + public required ThresholdTotalAmountConfig ThresholdTotalAmountConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "threshold_total_amount_config" + ); + } + init { this._rawData.Set("threshold_total_amount_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } -#pragma warning restore CS8618 - /// - public static RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary 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 { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.AdjustmentID = adjustmentID; + 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); -} + /// + /// 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); } + } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemovePrice : JsonModel -{ /// - /// The id of the price to remove from the plan. + /// The configuration for the rate of the price currency to the invoicing currency. /// - public required string PriceID + public ThresholdTotalAmountConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("conversion_rate_config", value); } } /// - /// The phase to remove this price from. + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. /// - public long? PlanPhaseOrder + public string? Currency { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableClass("currency"); } - init { this._rawData.Set("plan_phase_order", value); } + 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.PriceID; - _ = this.PlanPhaseOrder; + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("threshold_total_amount") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ThresholdTotalAmountConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; } - public RemovePrice() { } + public ThresholdTotalAmount() + { + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + } #pragma warning disable CS8618 [SetsRequiredMembers] - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } + public ThresholdTotalAmount(ThresholdTotalAmount thresholdTotalAmount) + : base(thresholdTotalAmount) { } #pragma warning restore CS8618 - public RemovePrice(IReadOnlyDictionary rawData) + public ThresholdTotalAmount(IReadOnlyDictionary rawData) { this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); } #pragma warning disable CS8618 [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + ThresholdTotalAmount(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static ThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() - { - this.PriceID = priceID; - } } -class RemovePriceFromRaw : IFromRawJson +class ThresholdTotalAmountFromRaw : IFromRawJson { /// - public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - RemovePrice.FromRawUnchecked(rawData); + public ThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmount.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplaceAdjustment : JsonModel +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ThresholdTotalAmountCadenceConverter))] +public enum ThresholdTotalAmountCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ThresholdTotalAmountCadenceConverter : JsonConverter +{ + public override ThresholdTotalAmountCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ThresholdTotalAmountCadence.Annual, + "semi_annual" => ThresholdTotalAmountCadence.SemiAnnual, + "monthly" => ThresholdTotalAmountCadence.Monthly, + "quarterly" => ThresholdTotalAmountCadence.Quarterly, + "one_time" => ThresholdTotalAmountCadence.OneTime, + "custom" => ThresholdTotalAmountCadence.Custom, + _ => (ThresholdTotalAmountCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ThresholdTotalAmountCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ThresholdTotalAmountCadence.Annual => "annual", + ThresholdTotalAmountCadence.SemiAnnual => "semi_annual", + ThresholdTotalAmountCadence.Monthly => "monthly", + ThresholdTotalAmountCadence.Quarterly => "quarterly", + ThresholdTotalAmountCadence.OneTime => "one_time", + ThresholdTotalAmountCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ThresholdTotalAmountLicenseAllocation, + ThresholdTotalAmountLicenseAllocationFromRaw + >) +)] +public sealed record class ThresholdTotalAmountLicenseAllocation : JsonModel { /// - /// The definition of a new adjustment to create and add to the plan. + /// The amount of credits granted per active license per cadence. /// - public required ReplaceAdjustmentAdjustment Adjustment + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("amount", value); } } /// - /// The id of the adjustment on the plan to replace in the plan. + /// The currency of the license allocation. /// - public required string ReplacesAdjustmentID + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("currency", value); } } /// - /// The phase to replace this adjustment from. + /// When True, overage beyond the allocation is written off. /// - public long? PlanPhaseOrder + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public ReplaceAdjustment() { } + public ThresholdTotalAmountLicenseAllocation() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } + public ThresholdTotalAmountLicenseAllocation( + ThresholdTotalAmountLicenseAllocation thresholdTotalAmountLicenseAllocation + ) + : base(thresholdTotalAmountLicenseAllocation) { } #pragma warning restore CS8618 - public ReplaceAdjustment(IReadOnlyDictionary rawData) + public ThresholdTotalAmountLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + ThresholdTotalAmountLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplaceAdjustment FromRawUnchecked( + /// + public static ThresholdTotalAmountLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8878,199 +9264,266 @@ IReadOnlyDictionary rawData } } -class ReplaceAdjustmentFromRaw : IFromRawJson +class ThresholdTotalAmountLicenseAllocationFromRaw + : IFromRawJson { /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); + public ThresholdTotalAmountLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmountLicenseAllocation.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the plan. +/// Configuration for threshold_total_amount pricing /// -[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class ThresholdTotalAmountConfig : JsonModel { - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json + /// + /// When the quantity consumed passes a provided threshold, the configured total + /// will be charged + /// + public required IReadOnlyList ConsumptionTable { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "consumption_table" ); } - } - - public string? Currency - { - get + init { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + this._rawData.Set>( + "consumption_table", + ImmutableArray.ToImmutableArray(value) ); } } - public bool? IsInvoiceLevel + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate { get { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); } + init { this._rawData.Set("prorate", value); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + foreach (var item in this.ConsumptionTable) + { + item.Validate(); + } + _ = this.Prorate; } - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + public ThresholdTotalAmountConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmountConfig(ThresholdTotalAmountConfig thresholdTotalAmountConfig) + : base(thresholdTotalAmountConfig) { } +#pragma warning restore CS8618 + + public ThresholdTotalAmountConfig(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdTotalAmountConfig(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + /// + public static ThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + [SetsRequiredMembers] + public ThresholdTotalAmountConfig(IReadOnlyList consumptionTable) + : this() { - this.Value = value; - this._element = element; + this.ConsumptionTable = consumptionTable; } +} - public ReplaceAdjustmentAdjustment(JsonElement element) +class ThresholdTotalAmountConfigFromRaw : IFromRawJson +{ + /// + public ThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmountConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single threshold +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ConsumptionTable : JsonModel +{ + public required string Threshold { - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold"); + } + init { this._rawData.Set("threshold", 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.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// + /// Total amount for this threshold /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public required string TotalAmount { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total_amount"); + } + init { this._rawData.Set("total_amount", 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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + /// + public override void Validate() { - value = this.Value as NewUsageDiscount; - return value != null; + _ = this.Threshold; + _ = this.TotalAmount; } - /// - /// 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 ConsumptionTable() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ConsumptionTable(ConsumptionTable consumptionTable) + : base(consumptionTable) { } +#pragma warning restore CS8618 + + public ConsumptionTable(IReadOnlyDictionary rawData) { - value = this.Value as NewAmountDiscount; - return value != null; + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ConsumptionTable(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ConsumptionTable FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ConsumptionTableFromRaw : IFromRawJson +{ + /// + public ConsumptionTable FromRawUnchecked(IReadOnlyDictionary rawData) => + ConsumptionTable.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ThresholdTotalAmountConversionRateConfigConverter))] +public record class ThresholdTotalAmountConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ThresholdTotalAmountConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ThresholdTotalAmountConversionRateConfig(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.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - value = this.Value as NewMinimum; + 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 . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - value = this.Value as NewMaximum; + value = this.Value as SharedTieredConversionRateConfig; return value != null; } @@ -9088,43 +9541,28 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// /// public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum + System::Action unit, + System::Action tiered ) { 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); + case SharedUnitConversionRateConfig value: + unit(value); break; - case NewMaximum value: - newMaximum(value); + case SharedTieredConversionRateConfig value: + tiered(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" + "Data did not match any variant of ThresholdTotalAmountConversionRateConfig" ); } } @@ -9144,48 +9582,34 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// /// public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum + System::Func unit, + System::Func tiered ) { return this.Value switch { - NewPercentageDiscount value => newPercentageDiscount(value), - NewUsageDiscount value => newUsageDiscount(value), - NewAmountDiscount value => newAmountDiscount(value), - NewMinimum value => newMinimum(value), - NewMaximum value => newMaximum(value), + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" + "Data did not match any variant of ThresholdTotalAmountConversionRateConfig" ), }; } - public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount 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 ThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); + public static implicit operator ThresholdTotalAmountConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -9202,19 +9626,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" + "Data did not match any variant of ThresholdTotalAmountConversionRateConfig" ); } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + public virtual bool Equals(ThresholdTotalAmountConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -9234,64 +9652,40 @@ int VariantIndex() { return this.Value switch { - NewPercentageDiscount _ => 0, - NewUsageDiscount _ => 1, - NewAmountDiscount _ => 2, - NewMinimum _ => 3, - NewMaximum _ => 4, + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, _ => -1, }; } } -sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter +sealed class ThresholdTotalAmountConversionRateConfigConverter + : JsonConverter { - public override ReplaceAdjustmentAdjustment? Read( + public override ThresholdTotalAmountConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; + string? conversionRateType; try { - adjustmentType = element.GetProperty("adjustment_type").GetString(); + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); } catch { - adjustmentType = null; + conversionRateType = null; } - switch (adjustmentType) + switch (conversionRateType) { - 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": + case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9309,11 +9703,11 @@ JsonSerializerOptions options return new(element); } - case "amount_discount": + case "tiered": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9331,54 +9725,16 @@ 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 ReplaceAdjustmentAdjustment(element); + return new ThresholdTotalAmountConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, + ThresholdTotalAmountConversionRateConfig value, JsonSerializerOptions options ) { @@ -9386,110 +9742,66330 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackage : JsonModel { /// - /// The id of the price on the plan to replace in the plan. + /// The cadence to bill for this price on. /// - public required string ReplacesPriceID + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); + return this._rawData.GetNotNullClass>("cadence"); } - init { this._rawData.Set("replaces_price_id", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The allocation price to add to the plan. + /// The id of the item the price will be associated with. /// - public NewAllocationPrice? AllocationPrice + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("allocation_price", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The phase to replace this price from. + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public long? PlanPhaseOrder + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("plan_phase_order", value); } } /// - /// New plan price request body params. + /// The pricing model type /// - public ReplacePricePrice? Price + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("price", value); } + init { this._rawData.Set("model_type", value); } } - /// - public override void Validate() + /// + /// The name of the price. + /// + public required string Name { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - _ = this.PlanPhaseOrder; - this.Price?.Validate(); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } } - public ReplacePrice() { } + /// + /// Configuration for tiered_package pricing + /// + public required TieredPackageConfig TieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tiered_package_config"); + } + init { this._rawData.Set("tiered_package_config", value); } + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } -#pragma warning restore CS8618 + /// + /// 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); } + } - public ReplacePrice(IReadOnlyDictionary 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 { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } } -#pragma warning restore CS8618 - /// - public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public TieredPackageConversionRateConfig? ConversionRateConfig { - this.ReplacesPriceID = replacesPriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } -} -class ReplacePriceFromRaw : IFromRawJson -{ - /// - public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplacePrice.FromRawUnchecked(rawData); + /// + /// 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackage(TieredPackage tieredPackage) + : base(tieredPackage) { } +#pragma warning restore CS8618 + + public TieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackage FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageFromRaw : IFromRawJson +{ + /// + public TieredPackage FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredPackageCadenceConverter))] +public enum TieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredPackageCadenceConverter : JsonConverter +{ + public override TieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredPackageCadence.Annual, + "semi_annual" => TieredPackageCadence.SemiAnnual, + "monthly" => TieredPackageCadence.Monthly, + "quarterly" => TieredPackageCadence.Quarterly, + "one_time" => TieredPackageCadence.OneTime, + "custom" => TieredPackageCadence.Custom, + _ => (TieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredPackageCadence.Annual => "annual", + TieredPackageCadence.SemiAnnual => "semi_annual", + TieredPackageCadence.Monthly => "monthly", + TieredPackageCadence.Quarterly => "quarterly", + TieredPackageCadence.OneTime => "one_time", + TieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageLicenseAllocation, + TieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class TieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageLicenseAllocation( + TieredPackageLicenseAllocation tieredPackageLicenseAllocation + ) + : base(tieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageLicenseAllocationFromRaw : IFromRawJson +{ + /// + public TieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_package pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackageConfig : JsonModel +{ + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. The tier bounds are defined + /// based on the total quantity rather than the number of packages, so they must + /// be multiples of the package size. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageConfig(TieredPackageConfig tieredPackageConfig) + : base(tieredPackageConfig) { } +#pragma warning restore CS8618 + + public TieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageConfigFromRaw : IFromRawJson +{ + /// + public TieredPackageConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier with business logic +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackageConfigTier : JsonModel +{ + /// + /// Price per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public TieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageConfigTier(TieredPackageConfigTier tieredPackageConfigTier) + : base(tieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public TieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public TieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredPackageConversionRateConfigConverter))] +public record class TieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageConversionRateConfig(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 TieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 TieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator TieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredPackageConversionRateConfig( + 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 TieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override TieredPackageConversionRateConfig? 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 TieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithMinimum : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_with_minimum pricing + /// + public required TieredWithMinimumConfig TieredWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_with_minimum_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 TieredWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimum(TieredWithMinimum tieredWithMinimum) + : base(tieredWithMinimum) { } +#pragma warning restore CS8618 + + public TieredWithMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumFromRaw : IFromRawJson +{ + /// + public TieredWithMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithMinimumCadenceConverter))] +public enum TieredWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithMinimumCadenceConverter : JsonConverter +{ + public override TieredWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredWithMinimumCadence.Annual, + "semi_annual" => TieredWithMinimumCadence.SemiAnnual, + "monthly" => TieredWithMinimumCadence.Monthly, + "quarterly" => TieredWithMinimumCadence.Quarterly, + "one_time" => TieredWithMinimumCadence.OneTime, + "custom" => TieredWithMinimumCadence.Custom, + _ => (TieredWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredWithMinimumCadence.Annual => "annual", + TieredWithMinimumCadence.SemiAnnual => "semi_annual", + TieredWithMinimumCadence.Monthly => "monthly", + TieredWithMinimumCadence.Quarterly => "quarterly", + TieredWithMinimumCadence.OneTime => "one_time", + TieredWithMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredWithMinimumLicenseAllocation, + TieredWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class TieredWithMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumLicenseAllocation( + TieredWithMinimumLicenseAllocation tieredWithMinimumLicenseAllocation + ) + : base(tieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithMinimumLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumLicenseAllocationFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_with_minimum pricing +/// +[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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// If true, tiers with an accrued amount of 0 will not be included in the rating. + /// + public bool? HideZeroAmountTiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hide_zero_amount_tiers"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hide_zero_amount_tiers", value); + } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prorate", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.HideZeroAmountTiers; + _ = this.Prorate; + } + + public TieredWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) + : base(tieredWithMinimumConfig) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithMinimumConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithMinimumConfigFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithMinimumConfigTier : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.MinimumAmount; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public TieredWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfigTier(TieredWithMinimumConfigTier tieredWithMinimumConfigTier) + : base(tieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithMinimumConversionRateConfigConverter))] +public record class TieredWithMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithMinimumConversionRateConfig(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 TieredWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 TieredWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator TieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredWithMinimumConversionRateConfig( + 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 TieredWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithMinimumConversionRateConfig? 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 TieredWithMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTiered : 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); } + } + + /// + /// Configuration for grouped_tiered pricing + /// + public required GroupedTieredConfig GroupedTieredConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouped_tiered_config"); + } + init { this._rawData.Set("grouped_tiered_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedTieredConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedTiered() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTiered(GroupedTiered groupedTiered) + : base(groupedTiered) { } +#pragma warning restore CS8618 + + public GroupedTiered(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTiered(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTiered FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredFromRaw : IFromRawJson +{ + /// + public GroupedTiered FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTiered.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedTieredCadenceConverter))] +public enum GroupedTieredCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedTieredCadenceConverter : JsonConverter +{ + public override GroupedTieredCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedTieredCadence.Annual, + "semi_annual" => GroupedTieredCadence.SemiAnnual, + "monthly" => GroupedTieredCadence.Monthly, + "quarterly" => GroupedTieredCadence.Quarterly, + "one_time" => GroupedTieredCadence.OneTime, + "custom" => GroupedTieredCadence.Custom, + _ => (GroupedTieredCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedTieredCadence.Annual => "annual", + GroupedTieredCadence.SemiAnnual => "semi_annual", + GroupedTieredCadence.Monthly => "monthly", + GroupedTieredCadence.Quarterly => "quarterly", + GroupedTieredCadence.OneTime => "one_time", + GroupedTieredCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredConfig : JsonModel +{ + /// + /// The billable metric property used to group before tiering + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Apply tiered pricing to each segment generated after grouping with the provided key + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public GroupedTieredConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) + : base(groupedTieredConfig) { } +#pragma warning restore CS8618 + + public GroupedTieredConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredConfigFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTieredConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredConfigTier : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public GroupedTieredConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) + : base(groupedTieredConfigTier) { } +#pragma warning restore CS8618 + + public GroupedTieredConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredConfigTierFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredLicenseAllocation, + GroupedTieredLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedTieredLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedTieredLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredLicenseAllocation( + GroupedTieredLicenseAllocation groupedTieredLicenseAllocation + ) + : base(groupedTieredLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedTieredLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredLicenseAllocationFromRaw : IFromRawJson +{ + /// + public GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedTieredConversionRateConfigConverter))] +public record class GroupedTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredConversionRateConfig(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 GroupedTieredConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedTieredConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedTieredConversionRateConfig( + 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 GroupedTieredConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedTieredConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedTieredConversionRateConfigConverter + : JsonConverter +{ + public override GroupedTieredConversionRateConfig? 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 GroupedTieredConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredPackageWithMinimum : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_package_with_minimum pricing + /// + public required TieredPackageWithMinimumConfig TieredPackageWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_package_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_package_with_minimum_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 TieredPackageWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredPackageWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimum(TieredPackageWithMinimum tieredPackageWithMinimum) + : base(tieredPackageWithMinimum) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredPackageWithMinimumCadenceConverter))] +public enum TieredPackageWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredPackageWithMinimumCadenceConverter + : JsonConverter +{ + public override TieredPackageWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredPackageWithMinimumCadence.Annual, + "semi_annual" => TieredPackageWithMinimumCadence.SemiAnnual, + "monthly" => TieredPackageWithMinimumCadence.Monthly, + "quarterly" => TieredPackageWithMinimumCadence.Quarterly, + "one_time" => TieredPackageWithMinimumCadence.OneTime, + "custom" => TieredPackageWithMinimumCadence.Custom, + _ => (TieredPackageWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredPackageWithMinimumCadence.Annual => "annual", + TieredPackageWithMinimumCadence.SemiAnnual => "semi_annual", + TieredPackageWithMinimumCadence.Monthly => "monthly", + TieredPackageWithMinimumCadence.Quarterly => "quarterly", + TieredPackageWithMinimumCadence.OneTime => "one_time", + TieredPackageWithMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumLicenseAllocation, + TieredPackageWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredPackageWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumLicenseAllocation( + TieredPackageWithMinimumLicenseAllocation tieredPackageWithMinimumLicenseAllocation + ) + : base(tieredPackageWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_package_with_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumConfig, + TieredPackageWithMinimumConfigFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumConfig : JsonModel +{ + public required double PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredPackageWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumConfig( + TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig + ) + : base(tieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumConfigFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumConfigTier, + TieredPackageWithMinimumConfigTierFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumConfigTier : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.MinimumAmount; + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public TieredPackageWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumConfigTier( + TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier + ) + : base(tieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumConfigTierFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredPackageWithMinimumConversionRateConfigConverter))] +public record class TieredPackageWithMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageWithMinimumConversionRateConfig(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 TieredPackageWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 TieredPackageWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator TieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredPackageWithMinimumConversionRateConfig( + 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 TieredPackageWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredPackageWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredPackageWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override TieredPackageWithMinimumConversionRateConfig? 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 TieredPackageWithMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PackageWithAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 package_with_allocation pricing + /// + public required PackageWithAllocationConfig PackageWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "package_with_allocation_config" + ); + } + init { this._rawData.Set("package_with_allocation_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 PackageWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("package_with_allocation") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.PackageWithAllocationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PackageWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocation(PackageWithAllocation packageWithAllocation) + : base(packageWithAllocation) { } +#pragma warning restore CS8618 + + public PackageWithAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationFromRaw : IFromRawJson +{ + /// + public PackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PackageWithAllocationCadenceConverter))] +public enum PackageWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PackageWithAllocationCadenceConverter : JsonConverter +{ + public override PackageWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PackageWithAllocationCadence.Annual, + "semi_annual" => PackageWithAllocationCadence.SemiAnnual, + "monthly" => PackageWithAllocationCadence.Monthly, + "quarterly" => PackageWithAllocationCadence.Quarterly, + "one_time" => PackageWithAllocationCadence.OneTime, + "custom" => PackageWithAllocationCadence.Custom, + _ => (PackageWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PackageWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PackageWithAllocationCadence.Annual => "annual", + PackageWithAllocationCadence.SemiAnnual => "semi_annual", + PackageWithAllocationCadence.Monthly => "monthly", + PackageWithAllocationCadence.Quarterly => "quarterly", + PackageWithAllocationCadence.OneTime => "one_time", + PackageWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PackageWithAllocationLicenseAllocation, + PackageWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class PackageWithAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public PackageWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocationLicenseAllocation( + PackageWithAllocationLicenseAllocation packageWithAllocationLicenseAllocation + ) + : base(packageWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public PackageWithAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public PackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for package_with_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PackageWithAllocationConfig : JsonModel +{ + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + public required string PackageAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_amount"); + } + init { this._rawData.Set("package_amount", value); } + } + + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.PackageAmount; + _ = this.PackageSize; + } + + public PackageWithAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocationConfig(PackageWithAllocationConfig packageWithAllocationConfig) + : base(packageWithAllocationConfig) { } +#pragma warning restore CS8618 + + public PackageWithAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationConfigFromRaw : IFromRawJson +{ + /// + public PackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PackageWithAllocationConversionRateConfigConverter))] +public record class PackageWithAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PackageWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PackageWithAllocationConversionRateConfig(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 PackageWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 PackageWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator PackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PackageWithAllocationConversionRateConfig( + 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 PackageWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PackageWithAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PackageWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override PackageWithAllocationConversionRateConfig? 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 PackageWithAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PackageWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithPercent : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 unit_with_percent pricing + /// + public required UnitWithPercentConfig UnitWithPercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_with_percent_config"); + } + init { this._rawData.Set("unit_with_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 UnitWithPercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_percent") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithPercentConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public UnitWithPercent() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercent(UnitWithPercent unitWithPercent) + : base(unitWithPercent) { } +#pragma warning restore CS8618 + + public UnitWithPercent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercent FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentFromRaw : IFromRawJson +{ + /// + public UnitWithPercent FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitWithPercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(UnitWithPercentCadenceConverter))] +public enum UnitWithPercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class UnitWithPercentCadenceConverter : JsonConverter +{ + public override UnitWithPercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => UnitWithPercentCadence.Annual, + "semi_annual" => UnitWithPercentCadence.SemiAnnual, + "monthly" => UnitWithPercentCadence.Monthly, + "quarterly" => UnitWithPercentCadence.Quarterly, + "one_time" => UnitWithPercentCadence.OneTime, + "custom" => UnitWithPercentCadence.Custom, + _ => (UnitWithPercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithPercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UnitWithPercentCadence.Annual => "annual", + UnitWithPercentCadence.SemiAnnual => "semi_annual", + UnitWithPercentCadence.Monthly => "monthly", + UnitWithPercentCadence.Quarterly => "quarterly", + UnitWithPercentCadence.OneTime => "one_time", + UnitWithPercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnitWithPercentLicenseAllocation, + UnitWithPercentLicenseAllocationFromRaw + >) +)] +public sealed record class UnitWithPercentLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public UnitWithPercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercentLicenseAllocation( + UnitWithPercentLicenseAllocation unitWithPercentLicenseAllocation + ) + : base(unitWithPercentLicenseAllocation) { } +#pragma warning restore CS8618 + + public UnitWithPercentLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercentLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentLicenseAllocationFromRaw : IFromRawJson +{ + /// + public UnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithPercentLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for unit_with_percent pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithPercentConfig : JsonModel +{ + /// + /// What percent, out of 100, of the calculated total to charge + /// + public required string Percent + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent"); + } + init { this._rawData.Set("percent", value); } + } + + /// + /// Rate per unit of usage + /// + 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.Percent; + _ = this.UnitAmount; + } + + public UnitWithPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercentConfig(UnitWithPercentConfig unitWithPercentConfig) + : base(unitWithPercentConfig) { } +#pragma warning restore CS8618 + + public UnitWithPercentConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercentConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentConfigFromRaw : IFromRawJson +{ + /// + public UnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithPercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UnitWithPercentConversionRateConfigConverter))] +public record class UnitWithPercentConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithPercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithPercentConversionRateConfig(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 UnitWithPercentConversionRateConfig" + ); + } + } + + /// + /// 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 UnitWithPercentConversionRateConfig" + ), + }; + } + + public static implicit operator UnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator UnitWithPercentConversionRateConfig( + 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 UnitWithPercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(UnitWithPercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class UnitWithPercentConversionRateConfigConverter + : JsonConverter +{ + public override UnitWithPercentConversionRateConfig? 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 UnitWithPercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithPercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixWithAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for matrix_with_allocation pricing + /// + public required MatrixWithAllocationConfig MatrixWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_allocation_config" + ); + } + init { this._rawData.Set("matrix_with_allocation_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 MatrixWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithAllocationConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MatrixWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithAllocation(MatrixWithAllocation matrixWithAllocation) + : base(matrixWithAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithAllocationFromRaw : IFromRawJson +{ + /// + public MatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixWithAllocationCadenceConverter))] +public enum MatrixWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixWithAllocationCadenceConverter : JsonConverter +{ + public override MatrixWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixWithAllocationCadence.Annual, + "semi_annual" => MatrixWithAllocationCadence.SemiAnnual, + "monthly" => MatrixWithAllocationCadence.Monthly, + "quarterly" => MatrixWithAllocationCadence.Quarterly, + "one_time" => MatrixWithAllocationCadence.OneTime, + "custom" => MatrixWithAllocationCadence.Custom, + _ => (MatrixWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixWithAllocationCadence.Annual => "annual", + MatrixWithAllocationCadence.SemiAnnual => "semi_annual", + MatrixWithAllocationCadence.Monthly => "monthly", + MatrixWithAllocationCadence.Quarterly => "quarterly", + MatrixWithAllocationCadence.OneTime => "one_time", + MatrixWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithAllocationLicenseAllocation, + MatrixWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class MatrixWithAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MatrixWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithAllocationLicenseAllocation( + MatrixWithAllocationLicenseAllocation matrixWithAllocationLicenseAllocation + ) + : base(matrixWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithAllocationConversionRateConfigConverter))] +public record class MatrixWithAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithAllocationConversionRateConfig(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 MatrixWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 MatrixWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator MatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MatrixWithAllocationConversionRateConfig( + 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 MatrixWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MatrixWithAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MatrixWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override MatrixWithAllocationConversionRateConfig? 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 MatrixWithAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithProration : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_with_proration pricing + /// + public required TieredWithProrationConfig 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. + /// + 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 TieredWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + 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(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 + + public TieredWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationFromRaw : IFromRawJson +{ + /// + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithProrationCadenceConverter : JsonConverter +{ + public override TieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + TieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredWithProrationLicenseAllocation, + TieredWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class TieredWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationLicenseAllocation( + TieredWithProrationLicenseAllocation tieredWithProrationLicenseAllocation + ) + : base(tieredWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public TieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfig : 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>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) + : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithProrationConfigFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfigTier : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + 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 TieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier + ) + : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig(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 TieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 TieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredWithProrationConversionRateConfig( + 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 TieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithProrationConversionRateConfig? 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 TieredWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithProration : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 unit_with_proration pricing + /// + public required UnitWithProrationConfig UnitWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "unit_with_proration_config" + ); + } + init { this._rawData.Set("unit_with_proration_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 UnitWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithProrationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public UnitWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProration(UnitWithProration unitWithProration) + : base(unitWithProration) { } +#pragma warning restore CS8618 + + public UnitWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithProrationFromRaw : IFromRawJson +{ + /// + public UnitWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(UnitWithProrationCadenceConverter))] +public enum UnitWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class UnitWithProrationCadenceConverter : JsonConverter +{ + public override UnitWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => UnitWithProrationCadence.Annual, + "semi_annual" => UnitWithProrationCadence.SemiAnnual, + "monthly" => UnitWithProrationCadence.Monthly, + "quarterly" => UnitWithProrationCadence.Quarterly, + "one_time" => UnitWithProrationCadence.OneTime, + "custom" => UnitWithProrationCadence.Custom, + _ => (UnitWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UnitWithProrationCadence.Annual => "annual", + UnitWithProrationCadence.SemiAnnual => "semi_annual", + UnitWithProrationCadence.Monthly => "monthly", + UnitWithProrationCadence.Quarterly => "quarterly", + UnitWithProrationCadence.OneTime => "one_time", + UnitWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnitWithProrationLicenseAllocation, + UnitWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class UnitWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public UnitWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationLicenseAllocation( + UnitWithProrationLicenseAllocation unitWithProrationLicenseAllocation + ) + : base(unitWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public UnitWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithProrationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public UnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for unit_with_proration pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithProrationConfig : JsonModel +{ + /// + /// Rate per unit of usage + /// + 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.UnitAmount; + } + + public UnitWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationConfig(UnitWithProrationConfig unitWithProrationConfig) + : base(unitWithProrationConfig) { } +#pragma warning restore CS8618 + + public UnitWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnitWithProrationConfig(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class UnitWithProrationConfigFromRaw : IFromRawJson +{ + /// + public UnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithProrationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UnitWithProrationConversionRateConfigConverter))] +public record class UnitWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithProrationConversionRateConfig(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 UnitWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 UnitWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator UnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator UnitWithProrationConversionRateConfig( + 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 UnitWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(UnitWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class UnitWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override UnitWithProrationConversionRateConfig? 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 UnitWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedAllocation : 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); } + } + + /// + /// Configuration for grouped_allocation pricing + /// + public required GroupedAllocationConfig GroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_allocation_config" + ); + } + init { this._rawData.Set("grouped_allocation_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocation(GroupedAllocation groupedAllocation) + : base(groupedAllocation) { } +#pragma warning restore CS8618 + + public GroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationFromRaw : IFromRawJson +{ + /// + public GroupedAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedAllocationCadenceConverter))] +public enum GroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedAllocationCadenceConverter : JsonConverter +{ + public override GroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedAllocationCadence.Annual, + "semi_annual" => GroupedAllocationCadence.SemiAnnual, + "monthly" => GroupedAllocationCadence.Monthly, + "quarterly" => GroupedAllocationCadence.Quarterly, + "one_time" => GroupedAllocationCadence.OneTime, + "custom" => GroupedAllocationCadence.Custom, + _ => (GroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedAllocationCadence.Annual => "annual", + GroupedAllocationCadence.SemiAnnual => "semi_annual", + GroupedAllocationCadence.Monthly => "monthly", + GroupedAllocationCadence.Quarterly => "quarterly", + GroupedAllocationCadence.OneTime => "one_time", + GroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_allocation pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedAllocationConfig : JsonModel +{ + /// + /// Usage allocation per group + /// + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + /// + /// How to determine the groups that should each be allocated some quantity + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Unit rate for post-allocation + /// + public required string OverageUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("overage_unit_rate"); + } + init { this._rawData.Set("overage_unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.GroupingKey; + _ = this.OverageUnitRate; + } + + public GroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationConfig(GroupedAllocationConfig groupedAllocationConfig) + : base(groupedAllocationConfig) { } +#pragma warning restore CS8618 + + public GroupedAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationConfigFromRaw : IFromRawJson +{ + /// + public GroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedAllocationLicenseAllocation, + GroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationLicenseAllocation( + GroupedAllocationLicenseAllocation groupedAllocationLicenseAllocation + ) + : base(groupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public GroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedAllocationConversionRateConfigConverter))] +public record class GroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedAllocationConversionRateConfig(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 GroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedAllocationConversionRateConfig( + 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 GroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override GroupedAllocationConversionRateConfig? 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 GroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithProration : JsonModel +{ + /// + /// Configuration for bulk_with_proration pricing + /// + public required BulkWithProrationConfig BulkWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_proration_config" + ); + } + init { this._rawData.Set("bulk_with_proration_config", value); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 BulkWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.BulkWithProrationConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("bulk_with_proration") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public BulkWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProration(BulkWithProration bulkWithProration) + : base(bulkWithProration) { } +#pragma warning restore CS8618 + + public BulkWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationFromRaw : IFromRawJson +{ + /// + public BulkWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithProration.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_proration pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithProrationConfig : JsonModel +{ + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public BulkWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationConfig(BulkWithProrationConfig bulkWithProrationConfig) + : base(bulkWithProrationConfig) { } +#pragma warning restore CS8618 + + public BulkWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BulkWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class BulkWithProrationConfigFromRaw : IFromRawJson +{ + /// + public BulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier with proration +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class BulkWithProrationConfigTier : JsonModel +{ + /// + /// Cost 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 BulkWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationConfigTier(BulkWithProrationConfigTier bulkWithProrationConfigTier) + : base(bulkWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public BulkWithProrationConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BulkWithProrationConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class BulkWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public BulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(BulkWithProrationCadenceConverter))] +public enum BulkWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class BulkWithProrationCadenceConverter : JsonConverter +{ + public override BulkWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => BulkWithProrationCadence.Annual, + "semi_annual" => BulkWithProrationCadence.SemiAnnual, + "monthly" => BulkWithProrationCadence.Monthly, + "quarterly" => BulkWithProrationCadence.Quarterly, + "one_time" => BulkWithProrationCadence.OneTime, + "custom" => BulkWithProrationCadence.Custom, + _ => (BulkWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithProrationCadence.Annual => "annual", + BulkWithProrationCadence.SemiAnnual => "semi_annual", + BulkWithProrationCadence.Monthly => "monthly", + BulkWithProrationCadence.Quarterly => "quarterly", + BulkWithProrationCadence.OneTime => "one_time", + BulkWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + BulkWithProrationLicenseAllocation, + BulkWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class BulkWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public BulkWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationLicenseAllocation( + BulkWithProrationLicenseAllocation bulkWithProrationLicenseAllocation + ) + : base(bulkWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public BulkWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public BulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(BulkWithProrationConversionRateConfigConverter))] +public record class BulkWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public BulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkWithProrationConversionRateConfig(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 BulkWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 BulkWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator BulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator BulkWithProrationConversionRateConfig( + 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 BulkWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(BulkWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class BulkWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override BulkWithProrationConversionRateConfig? 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 BulkWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithProratedMinimum : 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); } + } + + /// + /// Configuration for grouped_with_prorated_minimum pricing + /// + public required GroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_prorated_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_prorated_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithProratedMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithProratedMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_prorated_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithProratedMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimum(GroupedWithProratedMinimum groupedWithProratedMinimum) + : base(groupedWithProratedMinimum) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumFromRaw : IFromRawJson +{ + /// + public GroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithProratedMinimumCadenceConverter))] +public enum GroupedWithProratedMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithProratedMinimumCadenceConverter + : JsonConverter +{ + public override GroupedWithProratedMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedWithProratedMinimumCadence.Annual, + "semi_annual" => GroupedWithProratedMinimumCadence.SemiAnnual, + "monthly" => GroupedWithProratedMinimumCadence.Monthly, + "quarterly" => GroupedWithProratedMinimumCadence.Quarterly, + "one_time" => GroupedWithProratedMinimumCadence.OneTime, + "custom" => GroupedWithProratedMinimumCadence.Custom, + _ => (GroupedWithProratedMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithProratedMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithProratedMinimumCadence.Annual => "annual", + GroupedWithProratedMinimumCadence.SemiAnnual => "semi_annual", + GroupedWithProratedMinimumCadence.Monthly => "monthly", + GroupedWithProratedMinimumCadence.Quarterly => "quarterly", + GroupedWithProratedMinimumCadence.OneTime => "one_time", + GroupedWithProratedMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_prorated_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumConfig, + GroupedWithProratedMinimumConfigFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumConfig : JsonModel +{ + /// + /// How to determine the groups that should each have a minimum + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group + /// + public required string Minimum + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum"); + } + init { this._rawData.Set("minimum", value); } + } + + /// + /// The amount to charge per unit + /// + public required string UnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rate"); + } + init { this._rawData.Set("unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.Minimum; + _ = this.UnitRate; + } + + public GroupedWithProratedMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumConfig( + GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig + ) + : base(groupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumConfigFromRaw : IFromRawJson +{ + /// + public GroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumLicenseAllocation, + GroupedWithProratedMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithProratedMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumLicenseAllocation( + GroupedWithProratedMinimumLicenseAllocation groupedWithProratedMinimumLicenseAllocation + ) + : base(groupedWithProratedMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedWithProratedMinimumConversionRateConfigConverter))] +public record class GroupedWithProratedMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithProratedMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithProratedMinimumConversionRateConfig(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 GroupedWithProratedMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedWithProratedMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedWithProratedMinimumConversionRateConfig( + 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 GroupedWithProratedMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedWithProratedMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedWithProratedMinimumConversionRateConfigConverter + : JsonConverter +{ + public override GroupedWithProratedMinimumConversionRateConfig? 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 GroupedWithProratedMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithProratedMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithMeteredMinimum : 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); } + } + + /// + /// Configuration for grouped_with_metered_minimum pricing + /// + public required GroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_metered_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_metered_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithMeteredMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMeteredMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_metered_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithMeteredMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimum(GroupedWithMeteredMinimum groupedWithMeteredMinimum) + : base(groupedWithMeteredMinimum) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumFromRaw : IFromRawJson +{ + /// + public GroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithMeteredMinimumCadenceConverter))] +public enum GroupedWithMeteredMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithMeteredMinimumCadenceConverter + : JsonConverter +{ + public override GroupedWithMeteredMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedWithMeteredMinimumCadence.Annual, + "semi_annual" => GroupedWithMeteredMinimumCadence.SemiAnnual, + "monthly" => GroupedWithMeteredMinimumCadence.Monthly, + "quarterly" => GroupedWithMeteredMinimumCadence.Quarterly, + "one_time" => GroupedWithMeteredMinimumCadence.OneTime, + "custom" => GroupedWithMeteredMinimumCadence.Custom, + _ => (GroupedWithMeteredMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithMeteredMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithMeteredMinimumCadence.Annual => "annual", + GroupedWithMeteredMinimumCadence.SemiAnnual => "semi_annual", + GroupedWithMeteredMinimumCadence.Monthly => "monthly", + GroupedWithMeteredMinimumCadence.Quarterly => "quarterly", + GroupedWithMeteredMinimumCadence.OneTime => "one_time", + GroupedWithMeteredMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_metered_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumConfig, + GroupedWithMeteredMinimumConfigFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumConfig : JsonModel +{ + /// + /// Used to partition the usage into groups. The minimum amount is applied to + /// each group. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group per unit + /// + public required string MinimumUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_unit_amount"); + } + init { this._rawData.Set("minimum_unit_amount", value); } + } + + /// + /// Used to determine the unit rate + /// + public required string PricingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_key"); + } + init { this._rawData.Set("pricing_key", value); } + } + + /// + /// Scale the unit rates by the scaling factor. + /// + public required IReadOnlyList ScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("scaling_factors"); + } + init + { + this._rawData.Set>( + "scaling_factors", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Used to determine the unit rate scaling factor + /// + public required string ScalingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_key"); + } + init { this._rawData.Set("scaling_key", value); } + } + + /// + /// Apply per unit pricing to each pricing value. The minimum amount is applied + /// any unmatched usage. + /// + public required IReadOnlyList UnitAmounts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("unit_amounts"); + } + init + { + this._rawData.Set>( + "unit_amounts", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.MinimumUnitAmount; + _ = this.PricingKey; + foreach (var item in this.ScalingFactors) + { + item.Validate(); + } + _ = this.ScalingKey; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public GroupedWithMeteredMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumConfig( + GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig + ) + : base(groupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumConfigFromRaw : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a scaling factor +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ScalingFactor : JsonModel +{ + public required string ScalingFactorValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public required string ScalingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_value"); + } + init { this._rawData.Set("scaling_value", value); } + } + + /// + public override void Validate() + { + _ = this.ScalingFactorValue; + _ = this.ScalingValue; + } + + public ScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalingFactor(ScalingFactor scalingFactor) + : base(scalingFactor) { } +#pragma warning restore CS8618 + + public ScalingFactor(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalingFactor(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalingFactorFromRaw : IFromRawJson +{ + /// + public ScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) => + ScalingFactor.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a unit amount +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitAmount : JsonModel +{ + public required string PricingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_value"); + } + init { this._rawData.Set("pricing_value", value); } + } + + /// + /// Per unit amount + /// + public required string UnitAmountValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.PricingValue; + _ = this.UnitAmountValue; + } + + public UnitAmount() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitAmount(UnitAmount unitAmount) + : base(unitAmount) { } +#pragma warning restore CS8618 + + public UnitAmount(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitAmount(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitAmount FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitAmountFromRaw : IFromRawJson +{ + /// + public UnitAmount FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitAmount.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumLicenseAllocation, + GroupedWithMeteredMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithMeteredMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumLicenseAllocation( + GroupedWithMeteredMinimumLicenseAllocation groupedWithMeteredMinimumLicenseAllocation + ) + : base(groupedWithMeteredMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedWithMeteredMinimumConversionRateConfigConverter))] +public record class GroupedWithMeteredMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithMeteredMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithMeteredMinimumConversionRateConfig(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 GroupedWithMeteredMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedWithMeteredMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( + 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 GroupedWithMeteredMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedWithMeteredMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedWithMeteredMinimumConversionRateConfigConverter + : JsonConverter +{ + public override GroupedWithMeteredMinimumConversionRateConfig? 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 GroupedWithMeteredMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithMeteredMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithMinMaxThresholds : 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); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [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); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override GroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + GroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + 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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + ) + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 + + 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(JsonModelConverter< + GroupedWithMinMaxThresholdsLicenseAllocation, + GroupedWithMinMaxThresholdsLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithMinMaxThresholdsLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithMinMaxThresholdsLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsLicenseAllocation( + GroupedWithMinMaxThresholdsLicenseAllocation groupedWithMinMaxThresholdsLicenseAllocation + ) + : base(groupedWithMinMaxThresholdsLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholdsLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMinMaxThresholdsLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMinMaxThresholdsLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMinMaxThresholdsLicenseAllocation.FromRawUnchecked(rawData); +} + +[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) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +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); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixWithDisplayName : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for matrix_with_display_name pricing + /// + public required MatrixWithDisplayNameConfig MatrixWithDisplayNameConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_display_name_config" + ); + } + init { this._rawData.Set("matrix_with_display_name_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 MatrixWithDisplayNameConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithDisplayNameConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_display_name") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MatrixWithDisplayName() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) + : base(matrixWithDisplayName) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayName(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayName(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameFromRaw : IFromRawJson +{ + /// + public MatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayName.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixWithDisplayNameCadenceConverter))] +public enum MatrixWithDisplayNameCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixWithDisplayNameCadenceConverter : JsonConverter +{ + public override MatrixWithDisplayNameCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixWithDisplayNameCadence.Annual, + "semi_annual" => MatrixWithDisplayNameCadence.SemiAnnual, + "monthly" => MatrixWithDisplayNameCadence.Monthly, + "quarterly" => MatrixWithDisplayNameCadence.Quarterly, + "one_time" => MatrixWithDisplayNameCadence.OneTime, + "custom" => MatrixWithDisplayNameCadence.Custom, + _ => (MatrixWithDisplayNameCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithDisplayNameCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixWithDisplayNameCadence.Annual => "annual", + MatrixWithDisplayNameCadence.SemiAnnual => "semi_annual", + MatrixWithDisplayNameCadence.Monthly => "monthly", + MatrixWithDisplayNameCadence.Quarterly => "quarterly", + MatrixWithDisplayNameCadence.OneTime => "one_time", + MatrixWithDisplayNameCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameLicenseAllocation, + MatrixWithDisplayNameLicenseAllocationFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MatrixWithDisplayNameLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameLicenseAllocation( + MatrixWithDisplayNameLicenseAllocation matrixWithDisplayNameLicenseAllocation + ) + : base(matrixWithDisplayNameLicenseAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for matrix_with_display_name pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class MatrixWithDisplayNameConfig : 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 + /// + public required IReadOnlyList UnitAmounts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("unit_amounts"); + } + init + { + this._rawData.Set>( + "unit_amounts", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Dimension; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public MatrixWithDisplayNameConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameConfig(MatrixWithDisplayNameConfig matrixWithDisplayNameConfig) + : base(matrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameConfigFromRaw : IFromRawJson +{ + /// + public MatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a unit amount item +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameConfigUnitAmount, + MatrixWithDisplayNameConfigUnitAmountFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameConfigUnitAmount : JsonModel +{ + /// + /// The dimension value + /// + public required string DimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("dimension_value"); + } + init { this._rawData.Set("dimension_value", value); } + } + + /// + /// Display name for this dimension value + /// + public required string DisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("display_name"); + } + 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.DimensionValue; + _ = this.DisplayName; + _ = this.UnitAmount; + } + + public MatrixWithDisplayNameConfigUnitAmount() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameConfigUnitAmount( + MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount + ) + : base(matrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameConfigUnitAmount(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameConfigUnitAmount(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameConfigUnitAmountFromRaw + : IFromRawJson +{ + /// + public MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithDisplayNameConversionRateConfigConverter))] +public record class MatrixWithDisplayNameConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithDisplayNameConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithDisplayNameConversionRateConfig(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 MatrixWithDisplayNameConversionRateConfig" + ); + } + } + + /// + /// 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 MatrixWithDisplayNameConversionRateConfig" + ), + }; + } + + public static implicit operator MatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MatrixWithDisplayNameConversionRateConfig( + 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 MatrixWithDisplayNameConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MatrixWithDisplayNameConversionRateConfigConverter + : JsonConverter +{ + public override MatrixWithDisplayNameConversionRateConfig? 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 MatrixWithDisplayNameConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithDisplayNameConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredPackage : 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); } + } + + /// + /// Configuration for grouped_tiered_package pricing + /// + public required GroupedTieredPackageConfig GroupedTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_package_config" + ); + } + init { this._rawData.Set("grouped_tiered_package_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredPackageConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) + : base(groupedTieredPackage) { } +#pragma warning restore CS8618 + + public GroupedTieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedTieredPackageCadenceConverter))] +public enum GroupedTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedTieredPackageCadenceConverter : JsonConverter +{ + public override GroupedTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedTieredPackageCadence.Annual, + "semi_annual" => GroupedTieredPackageCadence.SemiAnnual, + "monthly" => GroupedTieredPackageCadence.Monthly, + "quarterly" => GroupedTieredPackageCadence.Quarterly, + "one_time" => GroupedTieredPackageCadence.OneTime, + "custom" => GroupedTieredPackageCadence.Custom, + _ => (GroupedTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedTieredPackageCadence.Annual => "annual", + GroupedTieredPackageCadence.SemiAnnual => "semi_annual", + GroupedTieredPackageCadence.Monthly => "monthly", + GroupedTieredPackageCadence.Quarterly => "quarterly", + GroupedTieredPackageCadence.OneTime => "one_time", + GroupedTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedTieredPackageConfig : JsonModel +{ + /// + /// The event property used to group before tiering + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public GroupedTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageConfig(GroupedTieredPackageConfig groupedTieredPackageConfig) + : base(groupedTieredPackageConfig) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageConfigFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredPackageConfigTier, + GroupedTieredPackageConfigTierFromRaw + >) +)] +public sealed record class GroupedTieredPackageConfigTier : JsonModel +{ + /// + /// Per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public GroupedTieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageConfigTier( + GroupedTieredPackageConfigTier groupedTieredPackageConfigTier + ) + : base(groupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredPackageLicenseAllocation, + GroupedTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedTieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageLicenseAllocation( + GroupedTieredPackageLicenseAllocation groupedTieredPackageLicenseAllocation + ) + : base(groupedTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedTieredPackageConversionRateConfigConverter))] +public record class GroupedTieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredPackageConversionRateConfig(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 GroupedTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedTieredPackageConversionRateConfig( + 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 GroupedTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override GroupedTieredPackageConversionRateConfig? 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 GroupedTieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MaxGroupTieredPackage : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for max_group_tiered_package pricing + /// + public required MaxGroupTieredPackageConfig MaxGroupTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "max_group_tiered_package_config" + ); + } + init { this._rawData.Set("max_group_tiered_package_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 MaxGroupTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MaxGroupTieredPackageConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("max_group_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MaxGroupTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) + : base(maxGroupTieredPackage) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MaxGroupTieredPackageCadenceConverter))] +public enum MaxGroupTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MaxGroupTieredPackageCadenceConverter : JsonConverter +{ + public override MaxGroupTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MaxGroupTieredPackageCadence.Annual, + "semi_annual" => MaxGroupTieredPackageCadence.SemiAnnual, + "monthly" => MaxGroupTieredPackageCadence.Monthly, + "quarterly" => MaxGroupTieredPackageCadence.Quarterly, + "one_time" => MaxGroupTieredPackageCadence.OneTime, + "custom" => MaxGroupTieredPackageCadence.Custom, + _ => (MaxGroupTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MaxGroupTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MaxGroupTieredPackageCadence.Annual => "annual", + MaxGroupTieredPackageCadence.SemiAnnual => "semi_annual", + MaxGroupTieredPackageCadence.Monthly => "monthly", + MaxGroupTieredPackageCadence.Quarterly => "quarterly", + MaxGroupTieredPackageCadence.OneTime => "one_time", + MaxGroupTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MaxGroupTieredPackageLicenseAllocation, + MaxGroupTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class MaxGroupTieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MaxGroupTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageLicenseAllocation( + MaxGroupTieredPackageLicenseAllocation maxGroupTieredPackageLicenseAllocation + ) + : base(maxGroupTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for max_group_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class MaxGroupTieredPackageConfig : JsonModel +{ + /// + /// The event property used to group before tiering the group with the highest value + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing to the largest group after grouping with the provided key. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public MaxGroupTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageConfig(MaxGroupTieredPackageConfig maxGroupTieredPackageConfig) + : base(maxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageConfigFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + MaxGroupTieredPackageConfigTier, + MaxGroupTieredPackageConfigTierFromRaw + >) +)] +public sealed record class MaxGroupTieredPackageConfigTier : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public MaxGroupTieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageConfigTier( + MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier + ) + : base(maxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MaxGroupTieredPackageConversionRateConfigConverter))] +public record class MaxGroupTieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MaxGroupTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MaxGroupTieredPackageConversionRateConfig(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 MaxGroupTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 MaxGroupTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator MaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MaxGroupTieredPackageConversionRateConfig( + 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 MaxGroupTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MaxGroupTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override MaxGroupTieredPackageConversionRateConfig? 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 MaxGroupTieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MaxGroupTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class ScalableMatrixWithUnitPricing : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 scalable_matrix_with_unit_pricing pricing + /// + public required ScalableMatrixWithUnitPricingConfig 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); } + } + + /// + /// 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 ScalableMatrixWithUnitPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithUnitPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ScalableMatrixWithUnitPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricing( + ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing + ) + : base(scalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricing(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricing(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCadenceConverter))] +public enum ScalableMatrixWithUnitPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ScalableMatrixWithUnitPricingCadenceConverter + : JsonConverter +{ + public override ScalableMatrixWithUnitPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ScalableMatrixWithUnitPricingCadence.Annual, + "semi_annual" => ScalableMatrixWithUnitPricingCadence.SemiAnnual, + "monthly" => ScalableMatrixWithUnitPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithUnitPricingCadence.Quarterly, + "one_time" => ScalableMatrixWithUnitPricingCadence.OneTime, + "custom" => ScalableMatrixWithUnitPricingCadence.Custom, + _ => (ScalableMatrixWithUnitPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithUnitPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ScalableMatrixWithUnitPricingCadence.Annual => "annual", + ScalableMatrixWithUnitPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithUnitPricingCadence.Monthly => "monthly", + ScalableMatrixWithUnitPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithUnitPricingCadence.OneTime => "one_time", + ScalableMatrixWithUnitPricingCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithUnitPricingLicenseAllocation, + ScalableMatrixWithUnitPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ScalableMatrixWithUnitPricingLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ScalableMatrixWithUnitPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingLicenseAllocation( + ScalableMatrixWithUnitPricingLicenseAllocation scalableMatrixWithUnitPricingLicenseAllocation + ) + : base(scalableMatrixWithUnitPricingLicenseAllocation) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricingLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricingLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for scalable_matrix_with_unit_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithUnitPricingConfig, + ScalableMatrixWithUnitPricingConfigFromRaw + >) +)] +public sealed record class ScalableMatrixWithUnitPricingConfig : 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 + /// + public required IReadOnlyList MatrixScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "matrix_scaling_factors" + ); + } + init + { + this._rawData.Set>( + "matrix_scaling_factors", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The final unit price to rate against the output of the matrix + /// + public required string UnitPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_price"); + } + init { this._rawData.Set("unit_price", value); } + } + + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init { this._rawData.Set("prorate", value); } + } + + /// + /// Used to determine the unit rate (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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + _ = this.UnitPrice; + _ = this.GroupingKey; + _ = this.Prorate; + _ = this.SecondDimension; + } + + public ScalableMatrixWithUnitPricingConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingConfig( + ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig + ) + : base(scalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricingConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricingConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingConfigFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricingConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixScalingFactor : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public MatrixScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixScalingFactor(MatrixScalingFactor matrixScalingFactor) + : base(matrixScalingFactor) { } +#pragma warning restore CS8618 + + public MatrixScalingFactor(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixScalingFactor(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixScalingFactorFromRaw : IFromRawJson +{ + /// + public MatrixScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixScalingFactor.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ScalableMatrixWithUnitPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithUnitPricingConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithUnitPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithUnitPricingConversionRateConfig(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 ScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ScalableMatrixWithUnitPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + 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 ScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter + : JsonConverter +{ + public override ScalableMatrixWithUnitPricingConversionRateConfig? 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 ScalableMatrixWithUnitPricingConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithUnitPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricing, + ScalableMatrixWithTieredPricingFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricing : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 scalable_matrix_with_tiered_pricing pricing + /// + public required ScalableMatrixWithTieredPricingConfig 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); } + } + + /// + /// 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 ScalableMatrixWithTieredPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithTieredPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ScalableMatrixWithTieredPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricing( + ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing + ) + : base(scalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricing(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricing(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCadenceConverter))] +public enum ScalableMatrixWithTieredPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ScalableMatrixWithTieredPricingCadenceConverter + : JsonConverter +{ + public override ScalableMatrixWithTieredPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ScalableMatrixWithTieredPricingCadence.Annual, + "semi_annual" => ScalableMatrixWithTieredPricingCadence.SemiAnnual, + "monthly" => ScalableMatrixWithTieredPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithTieredPricingCadence.Quarterly, + "one_time" => ScalableMatrixWithTieredPricingCadence.OneTime, + "custom" => ScalableMatrixWithTieredPricingCadence.Custom, + _ => (ScalableMatrixWithTieredPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithTieredPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ScalableMatrixWithTieredPricingCadence.Annual => "annual", + ScalableMatrixWithTieredPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithTieredPricingCadence.Monthly => "monthly", + ScalableMatrixWithTieredPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithTieredPricingCadence.OneTime => "one_time", + ScalableMatrixWithTieredPricingCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingLicenseAllocation, + ScalableMatrixWithTieredPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ScalableMatrixWithTieredPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingLicenseAllocation( + ScalableMatrixWithTieredPricingLicenseAllocation scalableMatrixWithTieredPricingLicenseAllocation + ) + : base(scalableMatrixWithTieredPricingLicenseAllocation) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for scalable_matrix_with_tiered_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfig, + ScalableMatrixWithTieredPricingConfigFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfig : JsonModel +{ + /// + /// Used for the scalable matrix first dimension + /// + 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 + >("matrix_scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.SecondDimension; + } + + public ScalableMatrixWithTieredPricingConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfig( + ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig + ) + : base(scalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor, + ScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfigMatrixScalingFactor : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) + : base(scalableMatrixWithTieredPricingConfigMatrixScalingFactor) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier entry with business logic +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfigTier, + ScalableMatrixWithTieredPricingConfigTierFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfigTier : 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 ScalableMatrixWithTieredPricingConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfigTier( + ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier + ) + : base(scalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigTierFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ScalableMatrixWithTieredPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithTieredPricingConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithTieredPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithTieredPricingConversionRateConfig(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 ScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ScalableMatrixWithTieredPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + 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 ScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter + : JsonConverter +{ + public override ScalableMatrixWithTieredPricingConversionRateConfig? 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 ScalableMatrixWithTieredPricingConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithTieredPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CumulativeGroupedBulk : 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); } + } + + /// + /// Configuration for cumulative_grouped_bulk pricing + /// + public required CumulativeGroupedBulkConfig CumulativeGroupedBulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_bulk_config" + ); + } + init { this._rawData.Set("cumulative_grouped_bulk_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 CumulativeGroupedBulkConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedBulkConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_bulk") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public CumulativeGroupedBulk() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) + : base(cumulativeGroupedBulk) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulk(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulk(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulk.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CumulativeGroupedBulkCadenceConverter))] +public enum CumulativeGroupedBulkCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CumulativeGroupedBulkCadenceConverter : JsonConverter +{ + public override CumulativeGroupedBulkCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => CumulativeGroupedBulkCadence.Annual, + "semi_annual" => CumulativeGroupedBulkCadence.SemiAnnual, + "monthly" => CumulativeGroupedBulkCadence.Monthly, + "quarterly" => CumulativeGroupedBulkCadence.Quarterly, + "one_time" => CumulativeGroupedBulkCadence.OneTime, + "custom" => CumulativeGroupedBulkCadence.Custom, + _ => (CumulativeGroupedBulkCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedBulkCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + CumulativeGroupedBulkCadence.Annual => "annual", + CumulativeGroupedBulkCadence.SemiAnnual => "semi_annual", + CumulativeGroupedBulkCadence.Monthly => "monthly", + CumulativeGroupedBulkCadence.Quarterly => "quarterly", + CumulativeGroupedBulkCadence.OneTime => "one_time", + CumulativeGroupedBulkCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_bulk pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CumulativeGroupedBulkConfig : JsonModel +{ + /// + /// Each tier lower bound must have the same group of values. + /// + public required IReadOnlyList DimensionValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "dimension_values" + ); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required string Group + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group"); + } + init { this._rawData.Set("group", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.DimensionValues) + { + item.Validate(); + } + _ = this.Group; + } + + public CumulativeGroupedBulkConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkConfig(CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig) + : base(cumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulkConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkConfigFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a dimension value entry +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DimensionValue : JsonModel +{ + /// + /// Grouping key value + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public DimensionValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DimensionValue(DimensionValue dimensionValue) + : base(dimensionValue) { } +#pragma warning restore CS8618 + + public DimensionValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DimensionValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DimensionValue FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DimensionValueFromRaw : IFromRawJson +{ + /// + public DimensionValue FromRawUnchecked(IReadOnlyDictionary rawData) => + DimensionValue.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedBulkLicenseAllocation, + CumulativeGroupedBulkLicenseAllocationFromRaw + >) +)] +public sealed record class CumulativeGroupedBulkLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public CumulativeGroupedBulkLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkLicenseAllocation( + CumulativeGroupedBulkLicenseAllocation cumulativeGroupedBulkLicenseAllocation + ) + : base(cumulativeGroupedBulkLicenseAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulkLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(CumulativeGroupedBulkConversionRateConfigConverter))] +public record class CumulativeGroupedBulkConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedBulkConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedBulkConversionRateConfig(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 CumulativeGroupedBulkConversionRateConfig" + ); + } + } + + /// + /// 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 CumulativeGroupedBulkConversionRateConfig" + ), + }; + } + + public static implicit operator CumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator CumulativeGroupedBulkConversionRateConfig( + 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 CumulativeGroupedBulkConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class CumulativeGroupedBulkConversionRateConfigConverter + : JsonConverter +{ + public override CumulativeGroupedBulkConversionRateConfig? 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 CumulativeGroupedBulkConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedBulkConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CumulativeGroupedAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 CumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public CumulativeGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + CumulativeGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationConfig : JsonModel +{ + /// + /// The overall allocation across all groups + /// + public required string CumulativeAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cumulative_allocation"); + } + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", 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.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } + + public CumulativeGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationLicenseAllocation, + CumulativeGroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public CumulativeGroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationLicenseAllocation( + CumulativeGroupedAllocationLicenseAllocation cumulativeGroupedAllocationLicenseAllocation + ) + : base(cumulativeGroupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig(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 CumulativeGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 CumulativeGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + 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 CumulativeGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationConversionRateConfig? 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 CumulativeGroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MinimumComposite : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for minimum_composite pricing + /// + public required MinimumCompositeConfig MinimumCompositeConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "minimum_composite_config" + ); + } + init { this._rawData.Set("minimum_composite_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 MinimumCompositeConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MinimumCompositeConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("minimum_composite") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MinimumComposite() + { + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumComposite(MinimumComposite minimumComposite) + : base(minimumComposite) { } +#pragma warning restore CS8618 + + public MinimumComposite(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumComposite(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumComposite FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MinimumCompositeFromRaw : IFromRawJson +{ + /// + public MinimumComposite FromRawUnchecked(IReadOnlyDictionary rawData) => + MinimumComposite.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MinimumCompositeCadenceConverter))] +public enum MinimumCompositeCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MinimumCompositeCadenceConverter : JsonConverter +{ + public override MinimumCompositeCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MinimumCompositeCadence.Annual, + "semi_annual" => MinimumCompositeCadence.SemiAnnual, + "monthly" => MinimumCompositeCadence.Monthly, + "quarterly" => MinimumCompositeCadence.Quarterly, + "one_time" => MinimumCompositeCadence.OneTime, + "custom" => MinimumCompositeCadence.Custom, + _ => (MinimumCompositeCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MinimumCompositeCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MinimumCompositeCadence.Annual => "annual", + MinimumCompositeCadence.SemiAnnual => "semi_annual", + MinimumCompositeCadence.Monthly => "monthly", + MinimumCompositeCadence.Quarterly => "quarterly", + MinimumCompositeCadence.OneTime => "one_time", + MinimumCompositeCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MinimumCompositeLicenseAllocation, + MinimumCompositeLicenseAllocationFromRaw + >) +)] +public sealed record class MinimumCompositeLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MinimumCompositeLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumCompositeLicenseAllocation( + MinimumCompositeLicenseAllocation minimumCompositeLicenseAllocation + ) + : base(minimumCompositeLicenseAllocation) { } +#pragma warning restore CS8618 + + public MinimumCompositeLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumCompositeLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MinimumCompositeLicenseAllocationFromRaw : IFromRawJson +{ + /// + public MinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MinimumCompositeLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for minimum_composite pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MinimumCompositeConfig : 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 MinimumCompositeConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumCompositeConfig(MinimumCompositeConfig minimumCompositeConfig) + : base(minimumCompositeConfig) { } +#pragma warning restore CS8618 + + public MinimumCompositeConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumCompositeConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public MinimumCompositeConfig(string minimumAmount) + : this() + { + this.MinimumAmount = minimumAmount; + } +} + +class MinimumCompositeConfigFromRaw : IFromRawJson +{ + /// + public MinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MinimumCompositeConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MinimumCompositeConversionRateConfigConverter))] +public record class MinimumCompositeConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MinimumCompositeConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MinimumCompositeConversionRateConfig(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 MinimumCompositeConversionRateConfig" + ); + } + } + + /// + /// 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 MinimumCompositeConversionRateConfig" + ), + }; + } + + public static implicit operator MinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MinimumCompositeConversionRateConfig( + 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 MinimumCompositeConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MinimumCompositeConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MinimumCompositeConversionRateConfigConverter + : JsonConverter +{ + public override MinimumCompositeConversionRateConfig? 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 MinimumCompositeConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MinimumCompositeConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +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>("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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 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 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public Percent() + { + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) + : base(percent) { } +#pragma warning restore CS8618 + + 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 Percent FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PercentFromRaw : IFromRawJson +{ + /// + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PercentCadenceConverter : JsonConverter +{ + public override PercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + PercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PercentLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public PercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentLicenseAllocation(PercentLicenseAllocation percentLicenseAllocation) + : base(percentLicenseAllocation) { } +#pragma warning restore CS8618 + + public PercentLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PercentLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PercentLicenseAllocationFromRaw : IFromRawJson +{ + /// + public PercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PercentLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for percent pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } +#pragma warning restore CS8618 + + 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 PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PercentConfig(double percent) + : this() + { + this.Percent = percent; + } +} + +class PercentConfigFromRaw : IFromRawJson +{ + /// + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(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 PercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator 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(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PercentConversionRateConfigConverter : JsonConverter +{ + public override 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 PercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +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>("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. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 EventOutputConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public EventOutput() + { + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } +#pragma warning restore CS8618 + + public EventOutput(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + EventOutput(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class EventOutputFromRaw : IFromRawJson +{ + /// + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class EventOutputCadenceConverter : JsonConverter +{ + public override EventOutputCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + EventOutputCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for event_output pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel +{ + /// + /// The key in the event data to extract the unit rate from. + /// + public required string UnitRatingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + 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.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; + } + + public EventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } +#pragma warning restore CS8618 + + 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 EventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public EventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +class EventOutputConfigFromRaw : IFromRawJson +{ + /// + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class EventOutputLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public EventOutputLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputLicenseAllocation(EventOutputLicenseAllocation eventOutputLicenseAllocation) + : base(eventOutputLicenseAllocation) { } +#pragma warning restore CS8618 + + public EventOutputLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + EventOutputLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static EventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class EventOutputLicenseAllocationFromRaw : IFromRawJson +{ + /// + public EventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => EventOutputLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(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 + ) + { + this.Value = value; + this._element = element; + } + + public EventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public EventOutputConversionRateConfig(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 EventOutputConversionRateConfig" + ); + } + } + + /// + /// 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 EventOutputConversionRateConfig" + ), + }; + } + + public static implicit operator EventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator EventOutputConversionRateConfig( + 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 EventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class EventOutputConversionRateConfigConverter + : JsonConverter +{ + public override EventOutputConversionRateConfig? 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 EventOutputConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + EventOutputConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// New plan price request body params. +/// +[JsonConverter(typeof(PriceConverter))] +public record class Price : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string ItemID + { + 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, + newPlanMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } + } + + public string Name + { + 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, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } + } + + public string? BillableMetricID + { + 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 bool? BilledInAdvance + { + 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 NewBillingCycleConfiguration? BillingCycleConfiguration + { + 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 double? ConversionRate + { + 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 string? Currency + { + 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 NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + 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 + ); + } + } + + public string? ExternalPriceID + { + 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 double? FixedPriceQuantity + { + 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 string? InvoiceGroupingKey + { + 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 + { + 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 + ); + } + } + + public string? LicenseTypeID + { + get + { + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + + 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, + newPlanMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } + } + + public Price(NewPlanUnitPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceBulkWithFilters value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceTieredWithProration value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceGroupedWithMinMaxThresholds value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanScalableMatrixWithTieredPricingPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceCumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PricePercent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceEventOutput value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(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.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + { + value = this.Value as NewPlanUnitPrice; + 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.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + { + value = this.Value as NewPlanTieredPrice; + 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.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + { + value = this.Value as NewPlanBulkPrice; + 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `PriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters([NotNullWhen(true)] out PriceBulkWithFilters? value) + { + value = this.Value as PriceBulkWithFilters; + 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.TryPickNewPlanPackage(out var value)) { + /// // `value` is of type `NewPlanPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + { + value = this.Value as NewPlanPackagePrice; + 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.TryPickNewPlanMatrix(out var value)) { + /// // `value` is of type `NewPlanMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + { + value = this.Value as NewPlanMatrixPrice; + 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.TryPickNewPlanThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanThresholdTotalAmount( + [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value + ) + { + value = this.Value as NewPlanThresholdTotalAmountPrice; + 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.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` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackageWithMinimum( + [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + ) + { + value = this.Value as NewPlanTieredPackageWithMinimumPrice; + 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.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value + ) + { + value = this.Value as NewPlanPackageWithAllocationPrice; + 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.TryPickNewPlanUnitWithPercent(out var value)) { + /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithPercent( + [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + ) + { + value = this.Value as NewPlanUnitWithPercentPrice; + 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.TryPickNewPlanMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + ) + { + value = this.Value as NewPlanMatrixWithAllocationPrice; + 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.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `PriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration([NotNullWhen(true)] out PriceTieredWithProration? value) + { + value = this.Value as PriceTieredWithProration; + 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.TryPickNewPlanUnitWithProration(out var value)) { + /// // `value` is of type `NewPlanUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithProration( + [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value + ) + { + 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 . + /// + /// 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 + ) + { + 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 . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// 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. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + ) + { + 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 . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + ) + { + 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 . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `PriceGroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out PriceGroupedWithMinMaxThresholds? value + ) + { + value = this.Value as PriceGroupedWithMinMaxThresholds; + 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.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; + } + + /// + /// 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; + } + + /// + /// 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 + ) + { + 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 . + /// + /// 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; + } + + /// + /// 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; + } + + /// + /// 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 `PriceCumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out PriceCumulativeGroupedAllocation? value + ) + { + value = this.Value as PriceCumulativeGroupedAllocation; + 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 `PricePercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out PricePercent? value) + { + value = this.Value as PricePercent; + 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 `PriceEventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) + { + value = this.Value as PriceEventOutput; + 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) => {...}, + /// (PriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (PriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (PriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (PricePercent value) => {...}, + /// (PriceEventOutput 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 + ) + { + switch (this.Value) + { + case NewPlanUnitPrice value: + newPlanUnit(value); + break; + case NewPlanTieredPrice value: + newPlanTiered(value); + break; + case NewPlanBulkPrice value: + newPlanBulk(value); + break; + case PriceBulkWithFilters 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 PriceTieredWithProration 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 PriceGroupedWithMinMaxThresholds 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 PriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewPlanMinimumCompositePrice value: + newPlanMinimumComposite(value); + break; + case PricePercent value: + percent(value); + break; + case PriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException("Data did not match any variant of Price"); + } + } + + /// + /// 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) => {...}, + /// (PriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (PriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (PriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (PricePercent value) => {...}, + /// (PriceEventOutput 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 + ) + { + return this.Value switch + { + NewPlanUnitPrice value => newPlanUnit(value), + NewPlanTieredPrice value => newPlanTiered(value), + NewPlanBulkPrice value => newPlanBulk(value), + PriceBulkWithFilters 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), + PriceTieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + PriceGroupedWithMinMaxThresholds 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), + PriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + PricePercent value => percent(value), + PriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), + }; + } + + public static implicit operator Price(NewPlanUnitPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPrice value) => new(value); + + public static implicit operator Price(NewPlanBulkPrice value) => new(value); + + public static implicit operator Price(PriceBulkWithFilters value) => new(value); + + public static implicit operator Price(NewPlanPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); + + public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); + + public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); + + public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); + + public static implicit operator Price(NewPlanMatrixWithAllocationPrice value) => new(value); + + public static implicit operator Price(PriceTieredWithProration value) => new(value); + + public static implicit operator Price(NewPlanUnitWithProrationPrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedAllocationPrice value) => new(value); + + public static implicit operator Price(NewPlanBulkWithProrationPrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedWithProratedMinimumPrice value) => + new(value); + + public static implicit operator Price(NewPlanGroupedWithMeteredMinimumPrice value) => + new(value); + + public static implicit operator Price(PriceGroupedWithMinMaxThresholds value) => new(value); + + public static implicit operator Price(NewPlanMatrixWithDisplayNamePrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedTieredPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanMaxGroupTieredPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanScalableMatrixWithUnitPricingPrice value) => + new(value); + + public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPrice value) => + new(value); + + public static implicit operator Price(NewPlanCumulativeGroupedBulkPrice value) => new(value); + + public static implicit operator Price(PriceCumulativeGroupedAllocation value) => new(value); + + public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); + + public static implicit operator Price(PricePercent 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 + /// (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 Price"); + } + 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() + ); + } + + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + PriceBulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + PriceTieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + PriceGroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + PriceCumulativeGroupedAllocation _ => 27, + NewPlanMinimumCompositePrice _ => 28, + PricePercent _ => 29, + PriceEventOutput _ => 30, + _ => -1, + }; + } +} + +sealed class PriceConverter : JsonConverter +{ + public override Price? 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_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 Price(element); + } + } + } + + public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value?.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PriceBulkWithFilters : JsonModel +{ + /// + /// Configuration for bulk_with_filters pricing + /// + public required PriceBulkWithFiltersBulkWithFiltersConfig 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>( + "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 PriceBulkWithFiltersConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceBulkWithFilters(PriceBulkWithFilters priceBulkWithFilters) + : base(priceBulkWithFilters) { } +#pragma warning restore CS8618 + + public PriceBulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public PriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceBulkWithFiltersBulkWithFiltersConfig, + PriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class PriceBulkWithFiltersBulkWithFiltersConfig : 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>( + "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>( + "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 PriceBulkWithFiltersBulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceBulkWithFiltersBulkWithFiltersConfig( + PriceBulkWithFiltersBulkWithFiltersConfig priceBulkWithFiltersBulkWithFiltersConfig + ) + : base(priceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public PriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceBulkWithFiltersBulkWithFiltersConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public PriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceBulkWithFiltersBulkWithFiltersConfigFilter, + PriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class PriceBulkWithFiltersBulkWithFiltersConfigFilter : 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 PriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceBulkWithFiltersBulkWithFiltersConfigFilter( + PriceBulkWithFiltersBulkWithFiltersConfigFilter priceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(priceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 + + public PriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceBulkWithFiltersBulkWithFiltersConfigFilter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public PriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceBulkWithFiltersBulkWithFiltersConfigTier, + PriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class PriceBulkWithFiltersBulkWithFiltersConfigTier : 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 PriceBulkWithFiltersBulkWithFiltersConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceBulkWithFiltersBulkWithFiltersConfigTier( + PriceBulkWithFiltersBulkWithFiltersConfigTier priceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(priceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 + + public PriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceBulkWithFiltersBulkWithFiltersConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class PriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public PriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceBulkWithFiltersCadenceConverter))] +public enum PriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceBulkWithFiltersCadenceConverter : JsonConverter +{ + public override PriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceBulkWithFiltersCadence.Annual, + "semi_annual" => PriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => PriceBulkWithFiltersCadence.Monthly, + "quarterly" => PriceBulkWithFiltersCadence.Quarterly, + "one_time" => PriceBulkWithFiltersCadence.OneTime, + "custom" => PriceBulkWithFiltersCadence.Custom, + _ => (PriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceBulkWithFiltersCadence.Annual => "annual", + PriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", + PriceBulkWithFiltersCadence.Monthly => "monthly", + PriceBulkWithFiltersCadence.Quarterly => "quarterly", + PriceBulkWithFiltersCadence.OneTime => "one_time", + PriceBulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(PriceBulkWithFiltersConversionRateConfigConverter))] +public record class PriceBulkWithFiltersConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceBulkWithFiltersConversionRateConfig(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 PriceBulkWithFiltersConversionRateConfig" + ); + } + } + + /// + /// 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 PriceBulkWithFiltersConversionRateConfig" + ), + }; + } + + public static implicit operator PriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceBulkWithFiltersConversionRateConfig( + 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 PriceBulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override PriceBulkWithFiltersConversionRateConfig? 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 PriceBulkWithFiltersConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceBulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PriceTieredWithProration : 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); } + } + + /// + /// 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 tiered_with_proration pricing + /// + public required PriceTieredWithProrationTieredWithProrationConfig 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. + /// + 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 PriceTieredWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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("tiered_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithProrationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceTieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceTieredWithProration(PriceTieredWithProration priceTieredWithProration) + : base(priceTieredWithProration) { } +#pragma warning restore CS8618 + + public PriceTieredWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceTieredWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceTieredWithProrationFromRaw : IFromRawJson +{ + /// + public PriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceTieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceTieredWithProrationCadenceConverter))] +public enum PriceTieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceTieredWithProrationCadenceConverter + : JsonConverter +{ + public override PriceTieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceTieredWithProrationCadence.Annual, + "semi_annual" => PriceTieredWithProrationCadence.SemiAnnual, + "monthly" => PriceTieredWithProrationCadence.Monthly, + "quarterly" => PriceTieredWithProrationCadence.Quarterly, + "one_time" => PriceTieredWithProrationCadence.OneTime, + "custom" => PriceTieredWithProrationCadence.Custom, + _ => (PriceTieredWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceTieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceTieredWithProrationCadence.Annual => "annual", + PriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + PriceTieredWithProrationCadence.Monthly => "monthly", + PriceTieredWithProrationCadence.Quarterly => "quarterly", + PriceTieredWithProrationCadence.OneTime => "one_time", + PriceTieredWithProrationCadence.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< + PriceTieredWithProrationTieredWithProrationConfig, + PriceTieredWithProrationTieredWithProrationConfigFromRaw + >) +)] +public sealed record class PriceTieredWithProrationTieredWithProrationConfig : 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 PriceTieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceTieredWithProrationTieredWithProrationConfig( + PriceTieredWithProrationTieredWithProrationConfig priceTieredWithProrationTieredWithProrationConfig + ) + : base(priceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public PriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceTieredWithProrationTieredWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class PriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public PriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceTieredWithProrationTieredWithProrationConfigTier, + PriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class PriceTieredWithProrationTieredWithProrationConfigTier : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + 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 PriceTieredWithProrationTieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceTieredWithProrationTieredWithProrationConfigTier( + PriceTieredWithProrationTieredWithProrationConfigTier priceTieredWithProrationTieredWithProrationConfigTier + ) + : base(priceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public PriceTieredWithProrationTieredWithProrationConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceTieredWithProrationTieredWithProrationConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public PriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceTieredWithProrationConversionRateConfigConverter))] +public record class PriceTieredWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceTieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceTieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceTieredWithProrationConversionRateConfig(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 PriceTieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 PriceTieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator PriceTieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceTieredWithProrationConversionRateConfig( + 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 PriceTieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceTieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceTieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override PriceTieredWithProrationConversionRateConfig? 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 PriceTieredWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceTieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceGroupedWithMinMaxThresholds, + PriceGroupedWithMinMaxThresholdsFromRaw + >) +)] +public sealed record class PriceGroupedWithMinMaxThresholds : 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); } + } + + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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. + /// + 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 PriceGroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceGroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceGroupedWithMinMaxThresholds( + PriceGroupedWithMinMaxThresholds priceGroupedWithMinMaxThresholds + ) + : base(priceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 + + public PriceGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceGroupedWithMinMaxThresholdsFromRaw : IFromRawJson +{ + /// + public PriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum PriceGroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override PriceGroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => PriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => PriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => PriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => PriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (PriceGroupedWithMinMaxThresholdsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceGroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + PriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + PriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + PriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + PriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_min_max_thresholds pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + >) +)] +public sealed record class PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) + : base(priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 + + public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson +{ + /// + public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class PriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceGroupedWithMinMaxThresholdsConversionRateConfig(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 PriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + } + + /// + /// 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 PriceGroupedWithMinMaxThresholdsConversionRateConfig" + ), + }; + } + + public static implicit operator PriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceGroupedWithMinMaxThresholdsConversionRateConfig( + 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 PriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceGroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter +{ + public override PriceGroupedWithMinMaxThresholdsConversionRateConfig? 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 PriceGroupedWithMinMaxThresholdsConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceGroupedWithMinMaxThresholdsConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceCumulativeGroupedAllocation, + PriceCumulativeGroupedAllocationFromRaw + >) +)] +public sealed record class PriceCumulativeGroupedAllocation : 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); } + } + + /// + /// Configuration for cumulative_grouped_allocation pricing + /// + public required PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); + } + init { this._rawData.Set("cumulative_grouped_allocation_config", 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 PriceCumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceCumulativeGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceCumulativeGroupedAllocation( + PriceCumulativeGroupedAllocation priceCumulativeGroupedAllocation + ) + : base(priceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 + + public PriceCumulativeGroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceCumulativeGroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceCumulativeGroupedAllocationFromRaw : IFromRawJson +{ + /// + public PriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceCumulativeGroupedAllocationCadenceConverter))] +public enum PriceCumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override PriceCumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => PriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => PriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => PriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => PriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => PriceCumulativeGroupedAllocationCadence.Custom, + _ => (PriceCumulativeGroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceCumulativeGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceCumulativeGroupedAllocationCadence.Annual => "annual", + PriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + PriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + PriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + PriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + PriceCumulativeGroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel +{ + /// + /// The overall allocation across all groups + /// + public required string CumulativeAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cumulative_allocation"); + } + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", 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.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } + + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) + : base(priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 + + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson +{ + /// + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class PriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceCumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceCumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceCumulativeGroupedAllocationConversionRateConfig(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 PriceCumulativeGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 PriceCumulativeGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator PriceCumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceCumulativeGroupedAllocationConversionRateConfig( + 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 PriceCumulativeGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override PriceCumulativeGroupedAllocationConversionRateConfig? 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 PriceCumulativeGroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceCumulativeGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PricePercent : 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); } + } + + /// + /// 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 PricePercentPercentConfig 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 PricePercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PricePercent() + { + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePercent(PricePercent pricePercent) + : base(pricePercent) { } +#pragma warning restore CS8618 + + public PricePercent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PricePercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PricePercent FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PricePercentFromRaw : IFromRawJson +{ + /// + public PricePercent FromRawUnchecked(IReadOnlyDictionary rawData) => + PricePercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PricePercentCadenceConverter))] +public enum PricePercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PricePercentCadenceConverter : JsonConverter +{ + public override PricePercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PricePercentCadence.Annual, + "semi_annual" => PricePercentCadence.SemiAnnual, + "monthly" => PricePercentCadence.Monthly, + "quarterly" => PricePercentCadence.Quarterly, + "one_time" => PricePercentCadence.OneTime, + "custom" => PricePercentCadence.Custom, + _ => (PricePercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PricePercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PricePercentCadence.Annual => "annual", + PricePercentCadence.SemiAnnual => "semi_annual", + PricePercentCadence.Monthly => "monthly", + PricePercentCadence.Quarterly => "quarterly", + PricePercentCadence.OneTime => "one_time", + PricePercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for percent pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PricePercentPercentConfig : 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 PricePercentPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePercentPercentConfig(PricePercentPercentConfig pricePercentPercentConfig) + : base(pricePercentPercentConfig) { } +#pragma warning restore CS8618 + + public PricePercentPercentConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PricePercentPercentConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PricePercentPercentConfig(double percent) + : this() + { + this.Percent = percent; + } +} + +class PricePercentPercentConfigFromRaw : IFromRawJson +{ + /// + public PricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePercentPercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PricePercentConversionRateConfigConverter))] +public record class PricePercentConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PricePercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PricePercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PricePercentConversionRateConfig(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 PricePercentConversionRateConfig" + ); + } + } + + /// + /// 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 PricePercentConversionRateConfig" + ), + }; + } + + public static implicit operator PricePercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PricePercentConversionRateConfig( + 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 PricePercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PricePercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PricePercentConversionRateConfigConverter + : JsonConverter +{ + public override PricePercentConversionRateConfig? 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 PricePercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PricePercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PriceEventOutput : 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); } + } + + /// + /// Configuration for event_output pricing + /// + public required PriceEventOutputEventOutputConfig 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. + /// + 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 PriceEventOutputConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PriceEventOutput() + { + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEventOutput(PriceEventOutput priceEventOutput) + : base(priceEventOutput) { } +#pragma warning restore CS8618 + + public PriceEventOutput(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEventOutput(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEventOutputFromRaw : IFromRawJson +{ + /// + public PriceEventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + PriceEventOutput.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceEventOutputCadenceConverter))] +public enum PriceEventOutputCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceEventOutputCadenceConverter : JsonConverter +{ + public override PriceEventOutputCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceEventOutputCadence.Annual, + "semi_annual" => PriceEventOutputCadence.SemiAnnual, + "monthly" => PriceEventOutputCadence.Monthly, + "quarterly" => PriceEventOutputCadence.Quarterly, + "one_time" => PriceEventOutputCadence.OneTime, + "custom" => PriceEventOutputCadence.Custom, + _ => (PriceEventOutputCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceEventOutputCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceEventOutputCadence.Annual => "annual", + PriceEventOutputCadence.SemiAnnual => "semi_annual", + PriceEventOutputCadence.Monthly => "monthly", + PriceEventOutputCadence.Quarterly => "quarterly", + PriceEventOutputCadence.OneTime => "one_time", + PriceEventOutputCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for event_output pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceEventOutputEventOutputConfig, + PriceEventOutputEventOutputConfigFromRaw + >) +)] +public sealed record class PriceEventOutputEventOutputConfig : JsonModel +{ + /// + /// The key in the event data to extract the unit rate from. + /// + public required string UnitRatingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + 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.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; + } + + public PriceEventOutputEventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEventOutputEventOutputConfig( + PriceEventOutputEventOutputConfig priceEventOutputEventOutputConfig + ) + : base(priceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 + + public PriceEventOutputEventOutputConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEventOutputEventOutputConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PriceEventOutputEventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +class PriceEventOutputEventOutputConfigFromRaw : IFromRawJson +{ + /// + public PriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceEventOutputEventOutputConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceEventOutputConversionRateConfigConverter))] +public record class PriceEventOutputConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEventOutputConversionRateConfig(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 PriceEventOutputConversionRateConfig" + ); + } + } + + /// + /// 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 PriceEventOutputConversionRateConfig" + ), + }; + } + + public static implicit operator PriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceEventOutputConversionRateConfig( + 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 PriceEventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceEventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceEventOutputConversionRateConfigConverter + : JsonConverter +{ + public override PriceEventOutputConversionRateConfig? 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 PriceEventOutputConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceEventOutputConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel +{ + /// + /// The id of the adjustment to remove from on the plan. + /// + public required string AdjustmentID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("adjustment_id"); + } + init { this._rawData.Set("adjustment_id", value); } + } + + /// + /// The phase to remove 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.AdjustmentID; + _ = this.PlanPhaseOrder; + } + + public RemoveAdjustment() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } +#pragma warning restore CS8618 + + 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 RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() + { + this.AdjustmentID = adjustmentID; + } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("plan_phase_order"); + } + init { this._rawData.Set("plan_phase_order", value); } + } + + /// + public override void Validate() + { + _ = this.PriceID; + _ = this.PlanPhaseOrder; + } + + public RemovePrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } +#pragma warning restore CS8618 + + 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 + { + 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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } +#pragma warning restore CS8618 + + 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 + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + 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 + ); + } + } + + public bool? IsInvoiceLevel + { + get + { + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel + ); + } + } + + 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) + { + this.Value = value; + this._element = element; + } + + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + { + this.Value = value; + this._element = 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 . + /// + /// 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) + { + 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; + } + + /// + /// 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; + } + + /// + /// 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 newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum + ) + { + 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" + ); + } + } + + /// + /// 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 + ) + { + 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" + ), + }; + } + + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount 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 + /// (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 ReplaceAdjustmentAdjustment" + ); + } + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); + } + + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } +} + +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter +{ + public override ReplaceAdjustmentAdjustment? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + 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 + } + + return new(element); + } + default: + { + return new ReplaceAdjustmentAdjustment(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplaceAdjustmentAdjustment value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_price_id"); + } + init { this._rawData.Set("replaces_price_id", value); } + } + + /// + /// 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 license allocation price to add to the plan. + /// + public ReplacePriceLicenseAllocationPrice? LicenseAllocationPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_allocation_price" + ); + } + init { this._rawData.Set("license_allocation_price", value); } + } + + /// + /// The phase to replace this price from. + /// + public long? PlanPhaseOrder + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("plan_phase_order"); + } + 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.ReplacesPriceID; + this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); + _ = this.PlanPhaseOrder; + this.Price?.Validate(); + } + + public ReplacePrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } +#pragma warning restore CS8618 + + public ReplacePrice(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePrice(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePrice(string replacesPriceID) + : this() + { + this.ReplacesPriceID = replacesPriceID; + } +} + +class ReplacePriceFromRaw : IFromRawJson +{ + /// + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); +} + +/// +/// The license allocation price to add to the plan. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceConverter))] +public record class ReplacePriceLicenseAllocationPrice : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string ItemID + { + get + { + return Match( + unit: (x) => x.ItemID, + tiered: (x) => x.ItemID, + bulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + package: (x) => x.ItemID, + matrix: (x) => x.ItemID, + thresholdTotalAmount: (x) => x.ItemID, + tieredPackage: (x) => x.ItemID, + tieredWithMinimum: (x) => x.ItemID, + groupedTiered: (x) => x.ItemID, + tieredPackageWithMinimum: (x) => x.ItemID, + packageWithAllocation: (x) => x.ItemID, + unitWithPercent: (x) => x.ItemID, + matrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + unitWithProration: (x) => x.ItemID, + groupedAllocation: (x) => x.ItemID, + bulkWithProration: (x) => x.ItemID, + groupedWithProratedMinimum: (x) => x.ItemID, + groupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + matrixWithDisplayName: (x) => x.ItemID, + groupedTieredPackage: (x) => x.ItemID, + maxGroupTieredPackage: (x) => x.ItemID, + scalableMatrixWithUnitPricing: (x) => x.ItemID, + scalableMatrixWithTieredPricing: (x) => x.ItemID, + cumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + minimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } + } + + public JsonElement ModelType + { + get + { + return Match( + unit: (x) => x.ModelType, + tiered: (x) => x.ModelType, + bulk: (x) => x.ModelType, + bulkWithFilters: (x) => x.ModelType, + package: (x) => x.ModelType, + matrix: (x) => x.ModelType, + thresholdTotalAmount: (x) => x.ModelType, + tieredPackage: (x) => x.ModelType, + tieredWithMinimum: (x) => x.ModelType, + groupedTiered: (x) => x.ModelType, + tieredPackageWithMinimum: (x) => x.ModelType, + packageWithAllocation: (x) => x.ModelType, + unitWithPercent: (x) => x.ModelType, + matrixWithAllocation: (x) => x.ModelType, + tieredWithProration: (x) => x.ModelType, + unitWithProration: (x) => x.ModelType, + groupedAllocation: (x) => x.ModelType, + bulkWithProration: (x) => x.ModelType, + groupedWithProratedMinimum: (x) => x.ModelType, + groupedWithMeteredMinimum: (x) => x.ModelType, + groupedWithMinMaxThresholds: (x) => x.ModelType, + matrixWithDisplayName: (x) => x.ModelType, + groupedTieredPackage: (x) => x.ModelType, + maxGroupTieredPackage: (x) => x.ModelType, + scalableMatrixWithUnitPricing: (x) => x.ModelType, + scalableMatrixWithTieredPricing: (x) => x.ModelType, + cumulativeGroupedBulk: (x) => x.ModelType, + cumulativeGroupedAllocation: (x) => x.ModelType, + minimumComposite: (x) => x.ModelType, + percent: (x) => x.ModelType, + eventOutput: (x) => x.ModelType + ); + } + } + + public string Name + { + get + { + return Match( + unit: (x) => x.Name, + tiered: (x) => x.Name, + bulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + package: (x) => x.Name, + matrix: (x) => x.Name, + thresholdTotalAmount: (x) => x.Name, + tieredPackage: (x) => x.Name, + tieredWithMinimum: (x) => x.Name, + groupedTiered: (x) => x.Name, + tieredPackageWithMinimum: (x) => x.Name, + packageWithAllocation: (x) => x.Name, + unitWithPercent: (x) => x.Name, + matrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + unitWithProration: (x) => x.Name, + groupedAllocation: (x) => x.Name, + bulkWithProration: (x) => x.Name, + groupedWithProratedMinimum: (x) => x.Name, + groupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + matrixWithDisplayName: (x) => x.Name, + groupedTieredPackage: (x) => x.Name, + maxGroupTieredPackage: (x) => x.Name, + scalableMatrixWithUnitPricing: (x) => x.Name, + scalableMatrixWithTieredPricing: (x) => x.Name, + cumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + minimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } + } + + public string? BillableMetricID + { + get + { + return Match( + unit: (x) => x.BillableMetricID, + tiered: (x) => x.BillableMetricID, + bulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + package: (x) => x.BillableMetricID, + matrix: (x) => x.BillableMetricID, + thresholdTotalAmount: (x) => x.BillableMetricID, + tieredPackage: (x) => x.BillableMetricID, + tieredWithMinimum: (x) => x.BillableMetricID, + groupedTiered: (x) => x.BillableMetricID, + tieredPackageWithMinimum: (x) => x.BillableMetricID, + packageWithAllocation: (x) => x.BillableMetricID, + unitWithPercent: (x) => x.BillableMetricID, + matrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + unitWithProration: (x) => x.BillableMetricID, + groupedAllocation: (x) => x.BillableMetricID, + bulkWithProration: (x) => x.BillableMetricID, + groupedWithProratedMinimum: (x) => x.BillableMetricID, + groupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + matrixWithDisplayName: (x) => x.BillableMetricID, + groupedTieredPackage: (x) => x.BillableMetricID, + maxGroupTieredPackage: (x) => x.BillableMetricID, + scalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + scalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + cumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + minimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } + } + + public bool? BilledInAdvance + { + get + { + return Match( + unit: (x) => x.BilledInAdvance, + tiered: (x) => x.BilledInAdvance, + bulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + package: (x) => x.BilledInAdvance, + matrix: (x) => x.BilledInAdvance, + thresholdTotalAmount: (x) => x.BilledInAdvance, + tieredPackage: (x) => x.BilledInAdvance, + tieredWithMinimum: (x) => x.BilledInAdvance, + groupedTiered: (x) => x.BilledInAdvance, + tieredPackageWithMinimum: (x) => x.BilledInAdvance, + packageWithAllocation: (x) => x.BilledInAdvance, + unitWithPercent: (x) => x.BilledInAdvance, + matrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + unitWithProration: (x) => x.BilledInAdvance, + groupedAllocation: (x) => x.BilledInAdvance, + bulkWithProration: (x) => x.BilledInAdvance, + groupedWithProratedMinimum: (x) => x.BilledInAdvance, + groupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + matrixWithDisplayName: (x) => x.BilledInAdvance, + groupedTieredPackage: (x) => x.BilledInAdvance, + maxGroupTieredPackage: (x) => x.BilledInAdvance, + scalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + scalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + cumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + minimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } + } + + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + return Match( + unit: (x) => x.BillingCycleConfiguration, + tiered: (x) => x.BillingCycleConfiguration, + bulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + package: (x) => x.BillingCycleConfiguration, + matrix: (x) => x.BillingCycleConfiguration, + thresholdTotalAmount: (x) => x.BillingCycleConfiguration, + tieredPackage: (x) => x.BillingCycleConfiguration, + tieredWithMinimum: (x) => x.BillingCycleConfiguration, + groupedTiered: (x) => x.BillingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + packageWithAllocation: (x) => x.BillingCycleConfiguration, + unitWithPercent: (x) => x.BillingCycleConfiguration, + matrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + unitWithProration: (x) => x.BillingCycleConfiguration, + groupedAllocation: (x) => x.BillingCycleConfiguration, + bulkWithProration: (x) => x.BillingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + matrixWithDisplayName: (x) => x.BillingCycleConfiguration, + groupedTieredPackage: (x) => x.BillingCycleConfiguration, + maxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + minimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } + } + + public double? ConversionRate + { + get + { + return Match( + unit: (x) => x.ConversionRate, + tiered: (x) => x.ConversionRate, + bulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + package: (x) => x.ConversionRate, + matrix: (x) => x.ConversionRate, + thresholdTotalAmount: (x) => x.ConversionRate, + tieredPackage: (x) => x.ConversionRate, + tieredWithMinimum: (x) => x.ConversionRate, + groupedTiered: (x) => x.ConversionRate, + tieredPackageWithMinimum: (x) => x.ConversionRate, + packageWithAllocation: (x) => x.ConversionRate, + unitWithPercent: (x) => x.ConversionRate, + matrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + unitWithProration: (x) => x.ConversionRate, + groupedAllocation: (x) => x.ConversionRate, + bulkWithProration: (x) => x.ConversionRate, + groupedWithProratedMinimum: (x) => x.ConversionRate, + groupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + matrixWithDisplayName: (x) => x.ConversionRate, + groupedTieredPackage: (x) => x.ConversionRate, + maxGroupTieredPackage: (x) => x.ConversionRate, + scalableMatrixWithUnitPricing: (x) => x.ConversionRate, + scalableMatrixWithTieredPricing: (x) => x.ConversionRate, + cumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + minimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } + } + + public string? Currency + { + get + { + return Match( + unit: (x) => x.Currency, + tiered: (x) => x.Currency, + bulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + package: (x) => x.Currency, + matrix: (x) => x.Currency, + thresholdTotalAmount: (x) => x.Currency, + tieredPackage: (x) => x.Currency, + tieredWithMinimum: (x) => x.Currency, + groupedTiered: (x) => x.Currency, + tieredPackageWithMinimum: (x) => x.Currency, + packageWithAllocation: (x) => x.Currency, + unitWithPercent: (x) => x.Currency, + matrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + unitWithProration: (x) => x.Currency, + groupedAllocation: (x) => x.Currency, + bulkWithProration: (x) => x.Currency, + groupedWithProratedMinimum: (x) => x.Currency, + groupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + matrixWithDisplayName: (x) => x.Currency, + groupedTieredPackage: (x) => x.Currency, + maxGroupTieredPackage: (x) => x.Currency, + scalableMatrixWithUnitPricing: (x) => x.Currency, + scalableMatrixWithTieredPricing: (x) => x.Currency, + cumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + minimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } + } + + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + return Match( + unit: (x) => x.DimensionalPriceConfiguration, + tiered: (x) => x.DimensionalPriceConfiguration, + bulk: (x) => x.DimensionalPriceConfiguration, + bulkWithFilters: (x) => x.DimensionalPriceConfiguration, + package: (x) => x.DimensionalPriceConfiguration, + matrix: (x) => x.DimensionalPriceConfiguration, + thresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + tieredPackage: (x) => x.DimensionalPriceConfiguration, + tieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + groupedTiered: (x) => x.DimensionalPriceConfiguration, + tieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + packageWithAllocation: (x) => x.DimensionalPriceConfiguration, + unitWithPercent: (x) => x.DimensionalPriceConfiguration, + matrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + tieredWithProration: (x) => x.DimensionalPriceConfiguration, + unitWithProration: (x) => x.DimensionalPriceConfiguration, + groupedAllocation: (x) => x.DimensionalPriceConfiguration, + bulkWithProration: (x) => x.DimensionalPriceConfiguration, + groupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, + matrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + groupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + maxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + minimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } + } + + public string? ExternalPriceID + { + get + { + return Match( + unit: (x) => x.ExternalPriceID, + tiered: (x) => x.ExternalPriceID, + bulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + package: (x) => x.ExternalPriceID, + matrix: (x) => x.ExternalPriceID, + thresholdTotalAmount: (x) => x.ExternalPriceID, + tieredPackage: (x) => x.ExternalPriceID, + tieredWithMinimum: (x) => x.ExternalPriceID, + groupedTiered: (x) => x.ExternalPriceID, + tieredPackageWithMinimum: (x) => x.ExternalPriceID, + packageWithAllocation: (x) => x.ExternalPriceID, + unitWithPercent: (x) => x.ExternalPriceID, + matrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + unitWithProration: (x) => x.ExternalPriceID, + groupedAllocation: (x) => x.ExternalPriceID, + bulkWithProration: (x) => x.ExternalPriceID, + groupedWithProratedMinimum: (x) => x.ExternalPriceID, + groupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + matrixWithDisplayName: (x) => x.ExternalPriceID, + groupedTieredPackage: (x) => x.ExternalPriceID, + maxGroupTieredPackage: (x) => x.ExternalPriceID, + scalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + scalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + cumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + minimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } + } + + public double? FixedPriceQuantity + { + get + { + return Match( + unit: (x) => x.FixedPriceQuantity, + tiered: (x) => x.FixedPriceQuantity, + bulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + package: (x) => x.FixedPriceQuantity, + matrix: (x) => x.FixedPriceQuantity, + thresholdTotalAmount: (x) => x.FixedPriceQuantity, + tieredPackage: (x) => x.FixedPriceQuantity, + tieredWithMinimum: (x) => x.FixedPriceQuantity, + groupedTiered: (x) => x.FixedPriceQuantity, + tieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + packageWithAllocation: (x) => x.FixedPriceQuantity, + unitWithPercent: (x) => x.FixedPriceQuantity, + matrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + unitWithProration: (x) => x.FixedPriceQuantity, + groupedAllocation: (x) => x.FixedPriceQuantity, + bulkWithProration: (x) => x.FixedPriceQuantity, + groupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + groupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + matrixWithDisplayName: (x) => x.FixedPriceQuantity, + groupedTieredPackage: (x) => x.FixedPriceQuantity, + maxGroupTieredPackage: (x) => x.FixedPriceQuantity, + scalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + scalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + cumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + minimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } + } + + public string? InvoiceGroupingKey + { + get + { + return Match( + unit: (x) => x.InvoiceGroupingKey, + tiered: (x) => x.InvoiceGroupingKey, + bulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + package: (x) => x.InvoiceGroupingKey, + matrix: (x) => x.InvoiceGroupingKey, + thresholdTotalAmount: (x) => x.InvoiceGroupingKey, + tieredPackage: (x) => x.InvoiceGroupingKey, + tieredWithMinimum: (x) => x.InvoiceGroupingKey, + groupedTiered: (x) => x.InvoiceGroupingKey, + tieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + packageWithAllocation: (x) => x.InvoiceGroupingKey, + unitWithPercent: (x) => x.InvoiceGroupingKey, + matrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + unitWithProration: (x) => x.InvoiceGroupingKey, + groupedAllocation: (x) => x.InvoiceGroupingKey, + bulkWithProration: (x) => x.InvoiceGroupingKey, + groupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + matrixWithDisplayName: (x) => x.InvoiceGroupingKey, + groupedTieredPackage: (x) => x.InvoiceGroupingKey, + maxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + scalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + scalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + cumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } + } + + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + return Match( + unit: (x) => x.InvoicingCycleConfiguration, + tiered: (x) => x.InvoicingCycleConfiguration, + bulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + package: (x) => x.InvoicingCycleConfiguration, + matrix: (x) => x.InvoicingCycleConfiguration, + thresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + tieredPackage: (x) => x.InvoicingCycleConfiguration, + tieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + groupedTiered: (x) => x.InvoicingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + packageWithAllocation: (x) => x.InvoicingCycleConfiguration, + unitWithPercent: (x) => x.InvoicingCycleConfiguration, + matrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + unitWithProration: (x) => x.InvoicingCycleConfiguration, + groupedAllocation: (x) => x.InvoicingCycleConfiguration, + bulkWithProration: (x) => x.InvoicingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + matrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + groupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + maxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + minimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } + } + + public string? LicenseTypeID + { + get + { + return Match( + unit: (x) => x.LicenseTypeID, + tiered: (x) => x.LicenseTypeID, + bulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + package: (x) => x.LicenseTypeID, + matrix: (x) => x.LicenseTypeID, + thresholdTotalAmount: (x) => x.LicenseTypeID, + tieredPackage: (x) => x.LicenseTypeID, + tieredWithMinimum: (x) => x.LicenseTypeID, + groupedTiered: (x) => x.LicenseTypeID, + tieredPackageWithMinimum: (x) => x.LicenseTypeID, + packageWithAllocation: (x) => x.LicenseTypeID, + unitWithPercent: (x) => x.LicenseTypeID, + matrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + unitWithProration: (x) => x.LicenseTypeID, + groupedAllocation: (x) => x.LicenseTypeID, + bulkWithProration: (x) => x.LicenseTypeID, + groupedWithProratedMinimum: (x) => x.LicenseTypeID, + groupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + matrixWithDisplayName: (x) => x.LicenseTypeID, + groupedTieredPackage: (x) => x.LicenseTypeID, + maxGroupTieredPackage: (x) => x.LicenseTypeID, + scalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + scalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + cumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + minimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + + public string? ReferenceID + { + get + { + return Match( + unit: (x) => x.ReferenceID, + tiered: (x) => x.ReferenceID, + bulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + package: (x) => x.ReferenceID, + matrix: (x) => x.ReferenceID, + thresholdTotalAmount: (x) => x.ReferenceID, + tieredPackage: (x) => x.ReferenceID, + tieredWithMinimum: (x) => x.ReferenceID, + groupedTiered: (x) => x.ReferenceID, + tieredPackageWithMinimum: (x) => x.ReferenceID, + packageWithAllocation: (x) => x.ReferenceID, + unitWithPercent: (x) => x.ReferenceID, + matrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + unitWithProration: (x) => x.ReferenceID, + groupedAllocation: (x) => x.ReferenceID, + bulkWithProration: (x) => x.ReferenceID, + groupedWithProratedMinimum: (x) => x.ReferenceID, + groupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + matrixWithDisplayName: (x) => x.ReferenceID, + groupedTieredPackage: (x) => x.ReferenceID, + maxGroupTieredPackage: (x) => x.ReferenceID, + scalableMatrixWithUnitPricing: (x) => x.ReferenceID, + scalableMatrixWithTieredPricing: (x) => x.ReferenceID, + cumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + minimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnit value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTiered value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulk value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulkWithFilters value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePackage value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrix value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceThresholdTotalAmount value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredPackage value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredWithMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedTiered value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePackageWithAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnitWithPercent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrixWithAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnitWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulkWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedTieredPackage value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMinimumComposite value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePercent value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceEventOutput value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPrice(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 `ReplacePriceLicenseAllocationPriceUnit` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceUnit? value) + { + value = this.Value as ReplacePriceLicenseAllocationPriceUnit; + 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 `ReplacePriceLicenseAllocationPriceTiered` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTiered? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTiered; + 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.TryPickBulk(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceBulk` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulk([NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceBulk? value) + { + value = this.Value as ReplacePriceLicenseAllocationPriceBulk; + 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceBulkWithFilters? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceBulkWithFilters; + 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.TryPickPackage(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPricePackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPackage( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPricePackage? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPricePackage; + 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.TryPickMatrix(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMatrix` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrix( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMatrix? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMatrix; + 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.TryPickThresholdTotalAmount(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceThresholdTotalAmount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickThresholdTotalAmount( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceThresholdTotalAmount? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceThresholdTotalAmount; + 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.TryPickTieredPackage(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceTieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredPackage( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTieredPackage? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTieredPackage; + 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.TryPickTieredWithMinimum(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceTieredWithMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithMinimum( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTieredWithMinimum? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTieredWithMinimum; + 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.TryPickGroupedTiered(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedTiered` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedTiered( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedTiered? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedTiered; + 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.TryPickTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredPackageWithMinimum( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum; + 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.TryPickPackageWithAllocation(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPricePackageWithAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPackageWithAllocation( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPricePackageWithAllocation? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPricePackageWithAllocation; + 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.TryPickUnitWithPercent(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceUnitWithPercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnitWithPercent( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceUnitWithPercent? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceUnitWithPercent; + 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.TryPickMatrixWithAllocation(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMatrixWithAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithAllocation( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMatrixWithAllocation? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMatrixWithAllocation; + 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.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceTieredWithProration? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceTieredWithProration; + 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.TryPickUnitWithProration(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceUnitWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnitWithProration( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceUnitWithProration? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceUnitWithProration; + 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.TryPickGroupedAllocation(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedAllocation( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedAllocation? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedAllocation; + 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.TryPickBulkWithProration(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceBulkWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithProration( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceBulkWithProration? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceBulkWithProration; + 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.TryPickGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithProratedMinimum( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum; + 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.TryPickGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMeteredMinimum( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum; + 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.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds; + 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.TryPickMatrixWithDisplayName(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMatrixWithDisplayName` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithDisplayName( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMatrixWithDisplayName? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMatrixWithDisplayName; + 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.TryPickGroupedTieredPackage(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceGroupedTieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedTieredPackage( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceGroupedTieredPackage? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceGroupedTieredPackage; + 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.TryPickMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMaxGroupTieredPackage( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage; + 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.TryPickScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickScalableMatrixWithUnitPricing( + [NotNullWhen(true)] + out ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing; + 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.TryPickScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickScalableMatrixWithTieredPricing( + [NotNullWhen(true)] + out ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing; + 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.TryPickCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedBulk( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk; + 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 `ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation; + 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.TryPickMinimumComposite(out var value)) { + /// // `value` is of type `ReplacePriceLicenseAllocationPriceMinimumComposite` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMinimumComposite( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceMinimumComposite? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceMinimumComposite; + 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 `ReplacePriceLicenseAllocationPricePercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPricePercent? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPricePercent; + 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 `ReplacePriceLicenseAllocationPriceEventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput( + [NotNullWhen(true)] out ReplacePriceLicenseAllocationPriceEventOutput? value + ) + { + value = this.Value as ReplacePriceLicenseAllocationPriceEventOutput; + 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( + /// (ReplacePriceLicenseAllocationPriceUnit value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTiered value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulk value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulkWithFilters value) => {...}, + /// (ReplacePriceLicenseAllocationPricePackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrix value) => {...}, + /// (ReplacePriceLicenseAllocationPriceThresholdTotalAmount value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredWithMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedTiered value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPricePackageWithAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceUnitWithPercent value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrixWithAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceUnitWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulkWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value) => {...}, + /// (ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value) => {...}, + /// (ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value) => {...}, + /// (ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMinimumComposite value) => {...}, + /// (ReplacePriceLicenseAllocationPricePercent value) => {...}, + /// (ReplacePriceLicenseAllocationPriceEventOutput value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered, + System::Action bulk, + System::Action bulkWithFilters, + System::Action package, + System::Action matrix, + System::Action thresholdTotalAmount, + System::Action tieredPackage, + System::Action tieredWithMinimum, + System::Action groupedTiered, + System::Action tieredPackageWithMinimum, + System::Action packageWithAllocation, + System::Action unitWithPercent, + System::Action matrixWithAllocation, + System::Action tieredWithProration, + System::Action unitWithProration, + System::Action groupedAllocation, + System::Action bulkWithProration, + System::Action groupedWithProratedMinimum, + System::Action groupedWithMeteredMinimum, + System::Action groupedWithMinMaxThresholds, + System::Action matrixWithDisplayName, + System::Action groupedTieredPackage, + System::Action maxGroupTieredPackage, + System::Action scalableMatrixWithUnitPricing, + System::Action scalableMatrixWithTieredPricing, + System::Action cumulativeGroupedBulk, + System::Action cumulativeGroupedAllocation, + System::Action minimumComposite, + System::Action percent, + System::Action eventOutput + ) + { + switch (this.Value) + { + case ReplacePriceLicenseAllocationPriceUnit value: + unit(value); + break; + case ReplacePriceLicenseAllocationPriceTiered value: + tiered(value); + break; + case ReplacePriceLicenseAllocationPriceBulk value: + bulk(value); + break; + case ReplacePriceLicenseAllocationPriceBulkWithFilters value: + bulkWithFilters(value); + break; + case ReplacePriceLicenseAllocationPricePackage value: + package(value); + break; + case ReplacePriceLicenseAllocationPriceMatrix value: + matrix(value); + break; + case ReplacePriceLicenseAllocationPriceThresholdTotalAmount value: + thresholdTotalAmount(value); + break; + case ReplacePriceLicenseAllocationPriceTieredPackage value: + tieredPackage(value); + break; + case ReplacePriceLicenseAllocationPriceTieredWithMinimum value: + tieredWithMinimum(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedTiered value: + groupedTiered(value); + break; + case ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value: + tieredPackageWithMinimum(value); + break; + case ReplacePriceLicenseAllocationPricePackageWithAllocation value: + packageWithAllocation(value); + break; + case ReplacePriceLicenseAllocationPriceUnitWithPercent value: + unitWithPercent(value); + break; + case ReplacePriceLicenseAllocationPriceMatrixWithAllocation value: + matrixWithAllocation(value); + break; + case ReplacePriceLicenseAllocationPriceTieredWithProration value: + tieredWithProration(value); + break; + case ReplacePriceLicenseAllocationPriceUnitWithProration value: + unitWithProration(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedAllocation value: + groupedAllocation(value); + break; + case ReplacePriceLicenseAllocationPriceBulkWithProration value: + bulkWithProration(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value: + groupedWithProratedMinimum(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value: + groupedWithMeteredMinimum(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value: + matrixWithDisplayName(value); + break; + case ReplacePriceLicenseAllocationPriceGroupedTieredPackage value: + groupedTieredPackage(value); + break; + case ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value: + maxGroupTieredPackage(value); + break; + case ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value: + scalableMatrixWithUnitPricing(value); + break; + case ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value: + scalableMatrixWithTieredPricing(value); + break; + case ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value: + cumulativeGroupedBulk(value); + break; + case ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case ReplacePriceLicenseAllocationPriceMinimumComposite value: + minimumComposite(value); + break; + case ReplacePriceLicenseAllocationPricePercent value: + percent(value); + break; + case ReplacePriceLicenseAllocationPriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPrice" + ); + } + } + + /// + /// 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( + /// (ReplacePriceLicenseAllocationPriceUnit value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTiered value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulk value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulkWithFilters value) => {...}, + /// (ReplacePriceLicenseAllocationPricePackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrix value) => {...}, + /// (ReplacePriceLicenseAllocationPriceThresholdTotalAmount value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredWithMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedTiered value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPricePackageWithAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceUnitWithPercent value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrixWithAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceTieredWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceUnitWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceBulkWithProration value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value) => {...}, + /// (ReplacePriceLicenseAllocationPriceGroupedTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value) => {...}, + /// (ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value) => {...}, + /// (ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value) => {...}, + /// (ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value) => {...}, + /// (ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value) => {...}, + /// (ReplacePriceLicenseAllocationPriceMinimumComposite value) => {...}, + /// (ReplacePriceLicenseAllocationPricePercent value) => {...}, + /// (ReplacePriceLicenseAllocationPriceEventOutput value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered, + System::Func bulk, + System::Func bulkWithFilters, + System::Func package, + System::Func matrix, + System::Func< + ReplacePriceLicenseAllocationPriceThresholdTotalAmount, + T + > thresholdTotalAmount, + System::Func tieredPackage, + System::Func tieredWithMinimum, + System::Func groupedTiered, + System::Func< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum, + T + > tieredPackageWithMinimum, + System::Func< + ReplacePriceLicenseAllocationPricePackageWithAllocation, + T + > packageWithAllocation, + System::Func unitWithPercent, + System::Func< + ReplacePriceLicenseAllocationPriceMatrixWithAllocation, + T + > matrixWithAllocation, + System::Func tieredWithProration, + System::Func unitWithProration, + System::Func groupedAllocation, + System::Func bulkWithProration, + System::Func< + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum, + T + > groupedWithProratedMinimum, + System::Func< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum, + T + > groupedWithMeteredMinimum, + System::Func< + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds, + T + > groupedWithMinMaxThresholds, + System::Func< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName, + T + > matrixWithDisplayName, + System::Func< + ReplacePriceLicenseAllocationPriceGroupedTieredPackage, + T + > groupedTieredPackage, + System::Func< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage, + T + > maxGroupTieredPackage, + System::Func< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing, + T + > scalableMatrixWithUnitPricing, + System::Func< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing, + T + > scalableMatrixWithTieredPricing, + System::Func< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk, + T + > cumulativeGroupedBulk, + System::Func< + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation, + T + > cumulativeGroupedAllocation, + System::Func minimumComposite, + System::Func percent, + System::Func eventOutput + ) + { + return this.Value switch + { + ReplacePriceLicenseAllocationPriceUnit value => unit(value), + ReplacePriceLicenseAllocationPriceTiered value => tiered(value), + ReplacePriceLicenseAllocationPriceBulk value => bulk(value), + ReplacePriceLicenseAllocationPriceBulkWithFilters value => bulkWithFilters(value), + ReplacePriceLicenseAllocationPricePackage value => package(value), + ReplacePriceLicenseAllocationPriceMatrix value => matrix(value), + ReplacePriceLicenseAllocationPriceThresholdTotalAmount value => thresholdTotalAmount( + value + ), + ReplacePriceLicenseAllocationPriceTieredPackage value => tieredPackage(value), + ReplacePriceLicenseAllocationPriceTieredWithMinimum value => tieredWithMinimum(value), + ReplacePriceLicenseAllocationPriceGroupedTiered value => groupedTiered(value), + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value => + tieredPackageWithMinimum(value), + ReplacePriceLicenseAllocationPricePackageWithAllocation value => packageWithAllocation( + value + ), + ReplacePriceLicenseAllocationPriceUnitWithPercent value => unitWithPercent(value), + ReplacePriceLicenseAllocationPriceMatrixWithAllocation value => matrixWithAllocation( + value + ), + ReplacePriceLicenseAllocationPriceTieredWithProration value => tieredWithProration( + value + ), + ReplacePriceLicenseAllocationPriceUnitWithProration value => unitWithProration(value), + ReplacePriceLicenseAllocationPriceGroupedAllocation value => groupedAllocation(value), + ReplacePriceLicenseAllocationPriceBulkWithProration value => bulkWithProration(value), + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value => + groupedWithProratedMinimum(value), + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value => + groupedWithMeteredMinimum(value), + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value => + groupedWithMinMaxThresholds(value), + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value => matrixWithDisplayName( + value + ), + ReplacePriceLicenseAllocationPriceGroupedTieredPackage value => groupedTieredPackage( + value + ), + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value => maxGroupTieredPackage( + value + ), + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value => + scalableMatrixWithUnitPricing(value), + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value => + scalableMatrixWithTieredPricing(value), + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value => cumulativeGroupedBulk( + value + ), + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value => + cumulativeGroupedAllocation(value), + ReplacePriceLicenseAllocationPriceMinimumComposite value => minimumComposite(value), + ReplacePriceLicenseAllocationPricePercent value => percent(value), + ReplacePriceLicenseAllocationPriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPrice" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnit value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTiered value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulk value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulkWithFilters value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePackage value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrix value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceThresholdTotalAmount value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredPackage value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredWithMinimum value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedTiered value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePackageWithAllocation value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnitWithPercent value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrixWithAllocation value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceTieredWithProration value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceUnitWithProration value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedAllocation value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceBulkWithProration value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceGroupedTieredPackage value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceMinimumComposite value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPricePercent value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPriceEventOutput 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 ReplacePriceLicenseAllocationPrice" + ); + } + this.Switch( + (unit) => unit.Validate(), + (tiered) => tiered.Validate(), + (bulk) => bulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (package) => package.Validate(), + (matrix) => matrix.Validate(), + (thresholdTotalAmount) => thresholdTotalAmount.Validate(), + (tieredPackage) => tieredPackage.Validate(), + (tieredWithMinimum) => tieredWithMinimum.Validate(), + (groupedTiered) => groupedTiered.Validate(), + (tieredPackageWithMinimum) => tieredPackageWithMinimum.Validate(), + (packageWithAllocation) => packageWithAllocation.Validate(), + (unitWithPercent) => unitWithPercent.Validate(), + (matrixWithAllocation) => matrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (unitWithProration) => unitWithProration.Validate(), + (groupedAllocation) => groupedAllocation.Validate(), + (bulkWithProration) => bulkWithProration.Validate(), + (groupedWithProratedMinimum) => groupedWithProratedMinimum.Validate(), + (groupedWithMeteredMinimum) => groupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (matrixWithDisplayName) => matrixWithDisplayName.Validate(), + (groupedTieredPackage) => groupedTieredPackage.Validate(), + (maxGroupTieredPackage) => maxGroupTieredPackage.Validate(), + (scalableMatrixWithUnitPricing) => scalableMatrixWithUnitPricing.Validate(), + (scalableMatrixWithTieredPricing) => scalableMatrixWithTieredPricing.Validate(), + (cumulativeGroupedBulk) => cumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (minimumComposite) => minimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); + } + + public virtual bool Equals(ReplacePriceLicenseAllocationPrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + ReplacePriceLicenseAllocationPriceUnit _ => 0, + ReplacePriceLicenseAllocationPriceTiered _ => 1, + ReplacePriceLicenseAllocationPriceBulk _ => 2, + ReplacePriceLicenseAllocationPriceBulkWithFilters _ => 3, + ReplacePriceLicenseAllocationPricePackage _ => 4, + ReplacePriceLicenseAllocationPriceMatrix _ => 5, + ReplacePriceLicenseAllocationPriceThresholdTotalAmount _ => 6, + ReplacePriceLicenseAllocationPriceTieredPackage _ => 7, + ReplacePriceLicenseAllocationPriceTieredWithMinimum _ => 8, + ReplacePriceLicenseAllocationPriceGroupedTiered _ => 9, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum _ => 10, + ReplacePriceLicenseAllocationPricePackageWithAllocation _ => 11, + ReplacePriceLicenseAllocationPriceUnitWithPercent _ => 12, + ReplacePriceLicenseAllocationPriceMatrixWithAllocation _ => 13, + ReplacePriceLicenseAllocationPriceTieredWithProration _ => 14, + ReplacePriceLicenseAllocationPriceUnitWithProration _ => 15, + ReplacePriceLicenseAllocationPriceGroupedAllocation _ => 16, + ReplacePriceLicenseAllocationPriceBulkWithProration _ => 17, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum _ => 18, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum _ => 19, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds _ => 20, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName _ => 21, + ReplacePriceLicenseAllocationPriceGroupedTieredPackage _ => 22, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage _ => 23, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing _ => 24, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing _ => 25, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk _ => 26, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation _ => 27, + ReplacePriceLicenseAllocationPriceMinimumComposite _ => 28, + ReplacePriceLicenseAllocationPricePercent _ => 29, + ReplacePriceLicenseAllocationPriceEventOutput _ => 30, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPrice? 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_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 ReplacePriceLicenseAllocationPrice(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPrice? value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value?.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnit, + ReplacePriceLicenseAllocationPriceUnitFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnit : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 unit pricing + /// + public required UnitConfig UnitConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_config"); + } + init { this._rawData.Set("unit_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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("unit"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceUnit() + { + this.ModelType = JsonSerializer.SerializeToElement("unit"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnit( + ReplacePriceLicenseAllocationPriceUnit replacePriceLicenseAllocationPriceUnit + ) + : base(replacePriceLicenseAllocationPriceUnit) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnit(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnit(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnit FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnit FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceUnit.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceUnitCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceUnitCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceUnitCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceUnitCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceUnitCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceUnitCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceUnitCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceUnitCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceUnitCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceUnitCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceUnitCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceUnitCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceUnitCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceUnitCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceUnitCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceUnitCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitLicenseAllocation, + ReplacePriceLicenseAllocationPriceUnitLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceUnitLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitLicenseAllocation( + ReplacePriceLicenseAllocationPriceUnitLicenseAllocation replacePriceLicenseAllocationPriceUnitLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceUnitLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceUnitLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceUnitConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceUnitConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceUnitConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitConversionRateConfig(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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePriceLicenseAllocationPriceUnitConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceUnitConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceUnitConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTiered, + ReplacePriceLicenseAllocationPriceTieredFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTiered : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered pricing + /// + public required TieredConfig TieredConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tiered_config"); + } + init { this._rawData.Set("tiered_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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("tiered"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTiered() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTiered( + ReplacePriceLicenseAllocationPriceTiered replacePriceLicenseAllocationPriceTiered + ) + : base(replacePriceLicenseAllocationPriceTiered) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTiered( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTiered(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTiered FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTiered FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTiered.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceTieredCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceTieredCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceTieredCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceTieredCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceTieredCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceTieredCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceTieredCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredLicenseAllocation replacePriceLicenseAllocationPriceTieredLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredConversionRateConfig(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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulk, + ReplacePriceLicenseAllocationPriceBulkFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulk : JsonModel +{ + /// + /// Configuration for bulk pricing + /// + public required BulkConfig BulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bulk_config"); + } + init { this._rawData.Set("bulk_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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.BulkConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("bulk"))) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceBulk() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulk( + ReplacePriceLicenseAllocationPriceBulk replacePriceLicenseAllocationPriceBulk + ) + : base(replacePriceLicenseAllocationPriceBulk) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulk(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulk(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceBulk.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceBulkCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceBulkCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceBulkCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceBulkCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceBulkCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceBulkCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceBulkCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceBulkCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceBulkCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceBulkCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceBulkCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceBulkCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceBulkCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceBulkCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceBulkCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceBulkCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkLicenseAllocation, + ReplacePriceLicenseAllocationPriceBulkLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceBulkLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkLicenseAllocation( + ReplacePriceLicenseAllocationPriceBulkLicenseAllocation replacePriceLicenseAllocationPriceBulkLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceBulkLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceBulkLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceBulkConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceBulkConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceBulkConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkConversionRateConfig(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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePriceLicenseAllocationPriceBulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceBulkConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceBulkConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFilters, + ReplacePriceLicenseAllocationPriceBulkWithFiltersFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFilters : JsonModel +{ + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig 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, + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFilters( + ReplacePriceLicenseAllocationPriceBulkWithFilters replacePriceLicenseAllocationPriceBulkWithFilters + ) + : base(replacePriceLicenseAllocationPriceBulkWithFilters) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFilters( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + : 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + : 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + : 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(replacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceBulkWithFiltersCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceBulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation, + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation( + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation replacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithFiltersLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackage, + ReplacePriceLicenseAllocationPricePackageFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackage : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 package pricing + /// + public required PackageConfig PackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_config"); + } + init { this._rawData.Set("package_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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("package"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.PackageConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPricePackage() + { + this.ModelType = JsonSerializer.SerializeToElement("package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackage( + ReplacePriceLicenseAllocationPricePackage replacePriceLicenseAllocationPricePackage + ) + : base(replacePriceLicenseAllocationPricePackage) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackage( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePackageCadenceConverter))] +public enum ReplacePriceLicenseAllocationPricePackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPricePackageCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPricePackageCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPricePackageCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPricePackageCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPricePackageCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPricePackageCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPricePackageCadence.Custom, + _ => (ReplacePriceLicenseAllocationPricePackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPricePackageCadence.Annual => "annual", + ReplacePriceLicenseAllocationPricePackageCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPricePackageCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPricePackageCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPricePackageCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPricePackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackageLicenseAllocation, + ReplacePriceLicenseAllocationPricePackageLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPricePackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackageLicenseAllocation( + ReplacePriceLicenseAllocationPricePackageLicenseAllocation replacePriceLicenseAllocationPricePackageLicenseAllocation + ) + : base(replacePriceLicenseAllocationPricePackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackageLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackageLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePackageLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePackageConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPricePackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPricePackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePackageConversionRateConfig(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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPricePackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPricePackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPricePackageConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPricePackageConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePackageConversionRateConfig? 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 ReplacePriceLicenseAllocationPricePackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrix, + ReplacePriceLicenseAllocationPriceMatrixFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrix : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for matrix pricing + /// + public required MatrixConfig MatrixConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("matrix_config"); + } + init { this._rawData.Set("matrix_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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixConfig.Validate(); + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("matrix"))) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMatrix() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrix( + ReplacePriceLicenseAllocationPriceMatrix replacePriceLicenseAllocationPriceMatrix + ) + : base(replacePriceLicenseAllocationPriceMatrix) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrix( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrix(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrix FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrix FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMatrix.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMatrixCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMatrixCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMatrixCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceMatrixCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMatrixCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMatrixCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMatrixCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMatrixCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMatrixCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMatrixCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMatrixCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceMatrixCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMatrixCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceMatrixCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceMatrixCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation, + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation( + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation replacePriceLicenseAllocationPriceMatrixLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMatrixLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMatrixLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMatrixConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig(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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceThresholdTotalAmount, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceThresholdTotalAmount : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 threshold_total_amount pricing + /// + public required ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig ThresholdTotalAmountConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "threshold_total_amount_config" + ); + } + init { this._rawData.Set("threshold_total_amount_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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("threshold_total_amount") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ThresholdTotalAmountConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmount() + { + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmount( + ReplacePriceLicenseAllocationPriceThresholdTotalAmount replacePriceLicenseAllocationPriceThresholdTotalAmount + ) + : base(replacePriceLicenseAllocationPriceThresholdTotalAmount) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmount( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceThresholdTotalAmount( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceThresholdTotalAmountFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceThresholdTotalAmount.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceThresholdTotalAmountCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation replacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceThresholdTotalAmountLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for threshold_total_amount pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + : JsonModel +{ + /// + /// When the quantity consumed passes a provided threshold, the configured total + /// will be charged + /// + public required IReadOnlyList ConsumptionTable + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("consumption_table"); + } + init + { + this._rawData.Set< + ImmutableArray + >("consumption_table", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init { this._rawData.Set("prorate", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.ConsumptionTable) + { + item.Validate(); + } + _ = this.Prorate; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig replacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig + ) + : base(replacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig( + IReadOnlyList consumptionTable + ) + : this() + { + this.ConsumptionTable = consumptionTable; + } +} + +class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single threshold +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTableFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + : JsonModel +{ + public required string Threshold + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold"); + } + init { this._rawData.Set("threshold", value); } + } + + /// + /// Total amount for this threshold + /// + public required string TotalAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total_amount"); + } + init { this._rawData.Set("total_amount", value); } + } + + /// + public override void Validate() + { + _ = this.Threshold; + _ = this.TotalAmount; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable replacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + ) + : base( + replacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTableFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceThresholdTotalAmountThresholdTotalAmountConfigConsumptionTable.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceThresholdTotalAmountConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackage, + ReplacePriceLicenseAllocationPriceTieredPackageFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackage : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered_package pricing + /// + public required ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig TieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_package_config" + ); + } + init { this._rawData.Set("tiered_package_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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackage( + ReplacePriceLicenseAllocationPriceTieredPackage replacePriceLicenseAllocationPriceTieredPackage + ) + : base(replacePriceLicenseAllocationPriceTieredPackage) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackage( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredPackageCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredPackageCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredPackageCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation replacePriceLicenseAllocationPriceTieredPackageLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig, + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + : JsonModel +{ + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. The tier bounds are defined + /// based on the total quantity rather than the number of packages, so they must + /// be multiples of the package size. + /// + 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() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig( + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig replacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig + ) + : base(replacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier with business logic +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier, + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + : JsonModel +{ + /// + /// Price per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier( + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier replacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier + ) + : base(replacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageTieredPackageConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig(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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithMinimum, + ReplacePriceLicenseAllocationPriceTieredWithMinimumFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithMinimum : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered_with_minimum pricing + /// + public required ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig TieredWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_with_minimum_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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimum( + ReplacePriceLicenseAllocationPriceTieredWithMinimum replacePriceLicenseAllocationPriceTieredWithMinimum + ) + : base(replacePriceLicenseAllocationPriceTieredWithMinimum) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithMinimum( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithMinimum( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithMinimumFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredWithMinimumCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredWithMinimumCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceTieredWithMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation replacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithMinimumLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for tiered_with_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig, + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + : JsonModel +{ + /// + /// Tiered pricing with a minimum amount dependent on the volume tier. Tiers + /// are defined using exclusive lower bounds. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// If true, tiers with an accrued amount of 0 will not be included in the rating. + /// + public bool? HideZeroAmountTiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hide_zero_amount_tiers"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hide_zero_amount_tiers", value); + } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prorate", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.HideZeroAmountTiers; + _ = this.Prorate; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig( + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig replacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig + ) + : base(replacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier, + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.MinimumAmount; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier( + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier replacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier + ) + : base(replacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithMinimumTieredWithMinimumConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTiered, + ReplacePriceLicenseAllocationPriceGroupedTieredFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTiered : 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); } + } + + /// + /// Configuration for grouped_tiered pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig GroupedTieredConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_config" + ); + } + init { this._rawData.Set("grouped_tiered_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedTiered() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTiered( + ReplacePriceLicenseAllocationPriceGroupedTiered replacePriceLicenseAllocationPriceGroupedTiered + ) + : base(replacePriceLicenseAllocationPriceGroupedTiered) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTiered( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTiered(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTiered FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTiered FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedTiered.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceGroupedTieredCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceGroupedTieredCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedTieredCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedTieredCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedTieredCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedTieredCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceGroupedTieredCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig, + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + : JsonModel +{ + /// + /// The billable metric property used to group before tiering + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Apply tiered pricing to each segment generated after grouping with the provided key + /// + 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() + { + _ = this.GroupingKey; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig( + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig replacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier, + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier( + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier replacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredGroupedTieredConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation replacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedTieredLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig(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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered_package_with_minimum pricing + /// + public required ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig TieredPackageWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_package_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_package_with_minimum_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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum replacePriceLicenseAllocationPriceTieredPackageWithMinimum + ) + : base(replacePriceLicenseAllocationPriceTieredPackageWithMinimum) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation replacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for tiered_package_with_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + : JsonModel +{ + public required double PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + 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() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig replacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + ) + : base( + replacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.MinimumAmount; + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier replacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + ) + : base( + replacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumTieredPackageWithMinimumConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredPackageWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackageWithAllocation, + ReplacePriceLicenseAllocationPricePackageWithAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackageWithAllocation : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 package_with_allocation pricing + /// + public required ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig PackageWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "package_with_allocation_config" + ); + } + init { this._rawData.Set("package_with_allocation_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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("package_with_allocation") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.PackageWithAllocationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackageWithAllocation( + ReplacePriceLicenseAllocationPricePackageWithAllocation replacePriceLicenseAllocationPricePackageWithAllocation + ) + : base(replacePriceLicenseAllocationPricePackageWithAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackageWithAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackageWithAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageWithAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePackageWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePackageWithAllocationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPricePackageWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPricePackageWithAllocationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePackageWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPricePackageWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPricePackageWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation, + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation( + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation replacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPricePackageWithAllocationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for package_with_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig, + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + : JsonModel +{ + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + public required string PackageAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_amount"); + } + init { this._rawData.Set("package_amount", value); } + } + + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.PackageAmount; + _ = this.PackageSize; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig( + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig replacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig + ) + : base(replacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPricePackageWithAllocationPackageWithAllocationConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig? 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 ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePackageWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithPercent, + ReplacePriceLicenseAllocationPriceUnitWithPercentFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithPercent : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 unit_with_percent pricing + /// + public required ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig UnitWithPercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "unit_with_percent_config" + ); + } + init { this._rawData.Set("unit_with_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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_percent") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithPercentConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercent() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithPercent( + ReplacePriceLicenseAllocationPriceUnitWithPercent replacePriceLicenseAllocationPriceUnitWithPercent + ) + : base(replacePriceLicenseAllocationPriceUnitWithPercent) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithPercent( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithPercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithPercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithPercentFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithPercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceUnitWithPercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceUnitWithPercentCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceUnitWithPercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceUnitWithPercentCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitWithPercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceUnitWithPercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceUnitWithPercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation, + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation( + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation replacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceUnitWithPercentLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for unit_with_percent pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig, + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + : JsonModel +{ + /// + /// What percent, out of 100, of the calculated total to charge + /// + public required string Percent + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent"); + } + init { this._rawData.Set("percent", value); } + } + + /// + /// Rate per unit of usage + /// + 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.Percent; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig( + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig replacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig + ) + : base(replacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceUnitWithPercentUnitWithPercentConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitWithPercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithAllocation, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithAllocation : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for matrix_with_allocation pricing + /// + public required MatrixWithAllocationConfig MatrixWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_allocation_config" + ); + } + init { this._rawData.Set("matrix_with_allocation_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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithAllocationConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithAllocation( + ReplacePriceLicenseAllocationPriceMatrixWithAllocation replacePriceLicenseAllocationPriceMatrixWithAllocation + ) + : base(replacePriceLicenseAllocationPriceMatrixWithAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMatrixWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceMatrixWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation( + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation replacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMatrixWithAllocationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithProration, + ReplacePriceLicenseAllocationPriceTieredWithProrationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithProration : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 tiered_with_proration pricing + /// + public required ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig 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. + /// + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + 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(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceTieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProration( + ReplacePriceLicenseAllocationPriceTieredWithProration replacePriceLicenseAllocationPriceTieredWithProration + ) + : base(replacePriceLicenseAllocationPriceTieredWithProration) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithProration( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithProration( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithProrationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceTieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceTieredWithProrationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceTieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceTieredWithProrationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceTieredWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceTieredWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation, + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation( + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation replacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithProrationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig, + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + : 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig( + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig replacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig + ) + : base(replacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier replacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier + ) + : base(replacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceTieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithProration, + ReplacePriceLicenseAllocationPriceUnitWithProrationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithProration : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 unit_with_proration pricing + /// + public required ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig UnitWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "unit_with_proration_config" + ); + } + init { this._rawData.Set("unit_with_proration_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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithProrationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithProration( + ReplacePriceLicenseAllocationPriceUnitWithProration replacePriceLicenseAllocationPriceUnitWithProration + ) + : base(replacePriceLicenseAllocationPriceUnitWithProration) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithProration( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithProration( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithProrationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceUnitWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceUnitWithProrationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceUnitWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceUnitWithProrationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceUnitWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceUnitWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation, + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation( + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation replacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceUnitWithProrationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for unit_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig, + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + : JsonModel +{ + /// + /// Rate per unit of usage + /// + 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.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig( + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig replacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig + ) + : base(replacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceUnitWithProrationUnitWithProrationConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceUnitWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedAllocation, + ReplacePriceLicenseAllocationPriceGroupedAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedAllocation : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_allocation pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig GroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_allocation_config" + ); + } + init { this._rawData.Set("grouped_allocation_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedAllocation( + ReplacePriceLicenseAllocationPriceGroupedAllocation replacePriceLicenseAllocationPriceGroupedAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceGroupedAllocationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedAllocationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceGroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig, + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + : JsonModel +{ + /// + /// Usage allocation per group + /// + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + /// + /// How to determine the groups that should each be allocated some quantity + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Unit rate for post-allocation + /// + public required string OverageUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("overage_unit_rate"); + } + init { this._rawData.Set("overage_unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.GroupingKey; + _ = this.OverageUnitRate; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig( + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig replacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig + ) + : base(replacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedAllocationGroupedAllocationConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation replacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedAllocationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithProration, + ReplacePriceLicenseAllocationPriceBulkWithProrationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithProration : JsonModel +{ + /// + /// Configuration for bulk_with_proration pricing + /// + public required ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig BulkWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_proration_config" + ); + } + init { this._rawData.Set("bulk_with_proration_config", value); } + } + + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.BulkWithProrationConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("bulk_with_proration") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceBulkWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProration( + ReplacePriceLicenseAllocationPriceBulkWithProration replacePriceLicenseAllocationPriceBulkWithProration + ) + : base(replacePriceLicenseAllocationPriceBulkWithProration) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithProration( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithProration( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithProrationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceBulkWithProration.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig, + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + : JsonModel +{ + /// + /// 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.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig( + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig replacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig + ) + : base(replacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single bulk pricing tier with proration +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier, + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + : JsonModel +{ + /// + /// Cost 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 ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier( + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier replacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier + ) + : base(replacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithProrationBulkWithProrationConfigTier.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceBulkWithProrationCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceBulkWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceBulkWithProrationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceBulkWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceBulkWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation, + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation( + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation replacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceBulkWithProrationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceBulkWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_with_prorated_minimum pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_prorated_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_prorated_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithProratedMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_prorated_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum replacePriceLicenseAllocationPriceGroupedWithProratedMinimum + ) + : base(replacePriceLicenseAllocationPriceGroupedWithProratedMinimum) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_prorated_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + : JsonModel +{ + /// + /// How to determine the groups that should each have a minimum + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group + /// + public required string Minimum + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum"); + } + init { this._rawData.Set("minimum", value); } + } + + /// + /// The amount to charge per unit + /// + public required string UnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rate"); + } + init { this._rawData.Set("unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.Minimum; + _ = this.UnitRate; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig replacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumGroupedWithProratedMinimumConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation replacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithProratedMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_with_metered_minimum pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_metered_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_metered_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMeteredMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_metered_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum replacePriceLicenseAllocationPriceGroupedWithMeteredMinimum + ) + : base(replacePriceLicenseAllocationPriceGroupedWithMeteredMinimum) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_metered_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + : JsonModel +{ + /// + /// Used to partition the usage into groups. The minimum amount is applied to + /// each group. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group per unit + /// + public required string MinimumUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_unit_amount"); + } + init { this._rawData.Set("minimum_unit_amount", value); } + } + + /// + /// Used to determine the unit rate + /// + public required string PricingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_key"); + } + init { this._rawData.Set("pricing_key", value); } + } + + /// + /// Scale the unit rates by the scaling factor. + /// + public required IReadOnlyList ScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Used to determine the unit rate scaling factor + /// + public required string ScalingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_key"); + } + init { this._rawData.Set("scaling_key", value); } + } + + /// + /// Apply per unit pricing to each pricing value. The minimum amount is applied + /// any unmatched usage. + /// + public required IReadOnlyList UnitAmounts + { + 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.GroupingKey; + _ = this.MinimumUnitAmount; + _ = this.PricingKey; + foreach (var item in this.ScalingFactors) + { + item.Validate(); + } + _ = this.ScalingKey; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + : JsonModel +{ + public required string ScalingFactor + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public required string ScalingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_value"); + } + init { this._rawData.Set("scaling_value", value); } + } + + /// + public override void Validate() + { + _ = this.ScalingFactor; + _ = this.ScalingValue; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a unit amount +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + : JsonModel +{ + public required string PricingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_value"); + } + init { this._rawData.Set("pricing_value", 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.PricingValue; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithMeteredMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence + > + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds + ) + : base(replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_min_max_thresholds pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) + : base( + replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedWithMinMaxThresholdsConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayName : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for matrix_with_display_name pricing + /// + public required ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig MatrixWithDisplayNameConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_display_name_config" + ); + } + init { this._rawData.Set("matrix_with_display_name_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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithDisplayNameConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_display_name") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayName() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayName( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName replacePriceLicenseAllocationPriceMatrixWithDisplayName + ) + : base(replacePriceLicenseAllocationPriceMatrixWithDisplayName) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayName( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithDisplayName( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMatrixWithDisplayName.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation replacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for matrix_with_display_name pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + : 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 + /// + public required IReadOnlyList UnitAmounts + { + 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(); + } + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig replacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig + ) + : base(replacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a unit amount item +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + : JsonModel +{ + /// + /// The dimension value + /// + public required string DimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("dimension_value"); + } + init { this._rawData.Set("dimension_value", value); } + } + + /// + /// Display name for this dimension value + /// + public required string DisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("display_name"); + } + 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.DimensionValue; + _ = this.DisplayName; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount replacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + ) + : base( + replacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMatrixWithDisplayNameConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredPackage, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredPackage : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_tiered_package pricing + /// + public required ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig GroupedTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_package_config" + ); + } + init { this._rawData.Set("grouped_tiered_package_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredPackageConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredPackage( + ReplacePriceLicenseAllocationPriceGroupedTieredPackage replacePriceLicenseAllocationPriceGroupedTieredPackage + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredPackage) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackage( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredPackage( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredPackageFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceGroupedTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceGroupedTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + : JsonModel +{ + /// + /// The event property used to group before tiering + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + 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() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig replacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + : JsonModel +{ + /// + /// Per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier replacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredPackageGroupedTieredPackageConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation replacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceGroupedTieredPackageLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceGroupedTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for max_group_tiered_package pricing + /// + public required ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig MaxGroupTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "max_group_tiered_package_config" + ); + } + init { this._rawData.Set("max_group_tiered_package_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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MaxGroupTieredPackageConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("max_group_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage replacePriceLicenseAllocationPriceMaxGroupTieredPackage + ) + : base(replacePriceLicenseAllocationPriceMaxGroupTieredPackage) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation replacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for max_group_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + : JsonModel +{ + /// + /// The event property used to group before tiering the group with the highest value + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing to the largest group after grouping with the provided key. + /// + 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() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig replacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig + ) + : base(replacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier replacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + ) + : base( + replacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageMaxGroupTieredPackageConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMaxGroupTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence + > + >("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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 scalable_matrix_with_unit_pricing pricing + /// + public required ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig 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); } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithUnitPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing + ) + : base(replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.OneTime, + "custom" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for scalable_matrix_with_unit_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + : 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 + /// + public required IReadOnlyList MatrixScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// The final unit price to rate against the output of the matrix + /// + public required string UnitPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_price"); + } + init { this._rawData.Set("unit_price", value); } + } + + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init { this._rawData.Set("prorate", value); } + } + + /// + /// Used to determine the unit rate (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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + _ = this.UnitPrice; + _ = this.GroupingKey; + _ = this.Prorate; + _ = this.SecondDimension; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceScalableMatrixWithUnitPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence + > + >("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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 scalable_matrix_with_tiered_pricing pricing + /// + public required ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig 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); } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithTieredPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing + ) + : base(replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.OneTime, + "custom" => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for scalable_matrix_with_tiered_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + : JsonModel +{ + /// + /// Used for the scalable matrix first dimension + /// + 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 + >("matrix_scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.SecondDimension; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tier entry with business logic +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + : 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + ) + : base( + replacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceScalableMatrixWithTieredPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for cumulative_grouped_bulk pricing + /// + public required ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig CumulativeGroupedBulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_bulk_config" + ); + } + init { this._rawData.Set("cumulative_grouped_bulk_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedBulkConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_bulk") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk replacePriceLicenseAllocationPriceCumulativeGroupedBulk + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedBulk) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulk.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_bulk pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + : JsonModel +{ + /// + /// Each tier lower bound must have the same group of values. + /// + public required IReadOnlyList DimensionValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("dimension_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("dimension_values", ImmutableArray.ToImmutableArray(value)); + } + } + + public required string Group + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group"); + } + init { this._rawData.Set("group", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.DimensionValues) + { + item.Validate(); + } + _ = this.Group; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig replacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig) + { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a dimension value entry +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + : JsonModel +{ + /// + /// Grouping key value + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue replacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + ) + : base( + replacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation replacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCumulativeGroupedBulkConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence + > + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for cumulative_grouped_allocation pricing + /// + public required ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); + } + init { this._rawData.Set("cumulative_grouped_allocation_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation replacePriceLicenseAllocationPriceCumulativeGroupedAllocation + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadenceConverter) +)] +public enum ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Annual => + "annual", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Monthly => + "monthly", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Quarterly => + "quarterly", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.OneTime => + "one_time", + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel +{ + /// + /// The overall allocation across all groups + /// + public required string CumulativeAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cumulative_allocation"); + } + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", 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.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) + : base( + replacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation replacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCumulativeGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMinimumComposite, + ReplacePriceLicenseAllocationPriceMinimumCompositeFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMinimumComposite : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence + > 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Configuration for minimum_composite pricing + /// + public required ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig MinimumCompositeConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "minimum_composite_config" + ); + } + init { this._rawData.Set("minimum_composite_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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MinimumCompositeConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("minimum_composite") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceMinimumComposite() + { + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMinimumComposite( + ReplacePriceLicenseAllocationPriceMinimumComposite replacePriceLicenseAllocationPriceMinimumComposite + ) + : base(replacePriceLicenseAllocationPriceMinimumComposite) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMinimumComposite( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMinimumComposite( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMinimumComposite FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMinimumCompositeFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMinimumComposite FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceMinimumComposite.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceMinimumCompositeCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceMinimumCompositeCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceMinimumCompositeCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMinimumCompositeCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceMinimumCompositeCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.SemiAnnual => + "semi_annual", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceMinimumCompositeCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation, + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation( + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation replacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMinimumCompositeLicenseAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for minimum_composite pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig, + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + : 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 ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig( + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig replacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig + ) + : base(replacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig( + string minimumAmount + ) + : this() + { + this.MinimumAmount = minimumAmount; + } +} + +class ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePriceLicenseAllocationPriceMinimumCompositeMinimumCompositeConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfigConverter) +)] +public record class ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceMinimumCompositeConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePercent, + ReplacePriceLicenseAllocationPricePercentFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePercent : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPricePercentPercentConfig 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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPricePercent() + { + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePercent( + ReplacePriceLicenseAllocationPricePercent replacePriceLicenseAllocationPricePercent + ) + : base(replacePriceLicenseAllocationPricePercent) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePercent( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePercentFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePercentCadenceConverter))] +public enum ReplacePriceLicenseAllocationPricePercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPricePercentCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPricePercentCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPricePercentCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPricePercentCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPricePercentCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPricePercentCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPricePercentCadence.Custom, + _ => (ReplacePriceLicenseAllocationPricePercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPricePercentCadence.Annual => "annual", + ReplacePriceLicenseAllocationPricePercentCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPricePercentCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPricePercentCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPricePercentCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPricePercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePercentLicenseAllocation, + ReplacePriceLicenseAllocationPricePercentLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePercentLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPricePercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePercentLicenseAllocation( + ReplacePriceLicenseAllocationPricePercentLicenseAllocation replacePriceLicenseAllocationPricePercentLicenseAllocation + ) + : base(replacePriceLicenseAllocationPricePercentLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePercentLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePercentLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPricePercentLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePercentLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for percent pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPricePercentPercentConfig, + ReplacePriceLicenseAllocationPricePercentPercentConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPricePercentPercentConfig : 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 ReplacePriceLicenseAllocationPricePercentPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePercentPercentConfig( + ReplacePriceLicenseAllocationPricePercentPercentConfig replacePriceLicenseAllocationPricePercentPercentConfig + ) + : base(replacePriceLicenseAllocationPricePercentPercentConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPricePercentPercentConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPricePercentPercentConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPricePercentPercentConfig(double percent) + : this() + { + this.Percent = percent; + } +} + +class ReplacePriceLicenseAllocationPricePercentPercentConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPricePercentPercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPricePercentConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPricePercentConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPricePercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPricePercentConversionRateConfig(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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPricePercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPricePercentConversionRateConfig( + 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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPricePercentConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPricePercentConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPricePercentConversionRateConfig? 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 ReplacePriceLicenseAllocationPricePercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPricePercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceEventOutput, + ReplacePriceLicenseAllocationPriceEventOutputFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceEventOutput : 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); } + } + + /// + /// Configuration for event_output pricing + /// + public required ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig 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. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set< + ImmutableArray + >("license_allocations", ImmutableArray.ToImmutableArray(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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ReplacePriceLicenseAllocationPriceEventOutput() + { + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceEventOutput( + ReplacePriceLicenseAllocationPriceEventOutput replacePriceLicenseAllocationPriceEventOutput + ) + : base(replacePriceLicenseAllocationPriceEventOutput) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceEventOutput( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceEventOutput(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceEventOutputFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceEventOutput.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceEventOutputCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceEventOutputCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceEventOutputCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceEventOutputCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceEventOutputCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceEventOutputCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceEventOutputCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceEventOutputCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceEventOutputCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceEventOutputCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceEventOutputCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceEventOutputCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceEventOutputCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceEventOutputCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceEventOutputCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceEventOutputCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceEventOutputCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for event_output pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig, + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfigFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig + : JsonModel +{ + /// + /// The key in the event data to extract the unit rate from. + /// + public required string UnitRatingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + 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.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; + } + + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig( + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig replacePriceLicenseAllocationPriceEventOutputEventOutputConfig + ) + : base(replacePriceLicenseAllocationPriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +class ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceEventOutputEventOutputConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation, + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation + : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation( + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation replacePriceLicenseAllocationPriceEventOutputLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceEventOutputLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceEventOutputLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig(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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig" + ); + } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + 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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig? 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 ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } } /// diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index 1b752cb6c..057c79810 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -49,10 +49,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// body of this request, Orb will also generate a one-off invoice for the customer /// for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, /// since the total charges on the invoice are calculated by multiplying the cost -/// basis with the number of credit units added. * if `per_unit_cost_basis` is greater -/// than zero, an invoice will be generated and `invoice_settings` must be included -/// * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` -/// is required to determine the due date +/// basis with the number of credit units added. If you invoice or handle payment +/// of credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in +/// the `invoice_settings` to `true` to prevent duplicate invoicing effects. * if +/// `per_unit_cost_basis` is greater than zero, an invoice will be generated and `invoice_settings` +/// must be included * if `invoice_settings` is passed, one of either `custom_due_date` +/// or `net_terms` is required to determine the due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer by /// creating an entry of type `decrement`. Orb matches the algorithm for automatic diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index f01db85fb..2640a762b 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -49,10 +49,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// body of this request, Orb will also generate a one-off invoice for the customer /// for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, /// since the total charges on the invoice are calculated by multiplying the cost -/// basis with the number of credit units added. * if `per_unit_cost_basis` is greater -/// than zero, an invoice will be generated and `invoice_settings` must be included -/// * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` -/// is required to determine the due date +/// basis with the number of credit units added. If you invoice or handle payment +/// of credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in +/// the `invoice_settings` to `true` to prevent duplicate invoicing effects. * if +/// `per_unit_cost_basis` is greater than zero, an invoice will be generated and `invoice_settings` +/// must be included * if `invoice_settings` is passed, one of either `custom_due_date` +/// or `net_terms` is required to determine the due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer by /// creating an entry of type `decrement`. Orb matches the algorithm for automatic diff --git a/src/Orb/Models/Plans/PlanCreateParams.cs b/src/Orb/Models/Plans/PlanCreateParams.cs index c2cf8b7da..9bc44d795 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -319,75 +319,32275 @@ public NewAllocationPrice? AllocationPrice init { this._rawData.Set("allocation_price", value); } } + /// + /// The license allocation price to add to the plan. + /// + public LicenseAllocationPrice? LicenseAllocationPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_allocation_price" + ); + } + init { this._rawData.Set("license_allocation_price", value); } + } + /// /// The phase to add this price to. /// public long? PlanPhaseOrder { - get + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("plan_phase_order"); + } + init { this._rawData.Set("plan_phase_order", value); } + } + + /// + /// New plan price request body params. + /// + public PricePrice? PriceValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("price"); + } + init { this._rawData.Set("price", value); } + } + + /// + public override void Validate() + { + this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); + _ = this.PlanPhaseOrder; + this.PriceValue?.Validate(); + } + + public Price() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Price(Price price) + : base(price) { } +#pragma warning restore CS8618 + + public Price(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Price(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Price FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceFromRaw : IFromRawJson +{ + /// + public Price FromRawUnchecked(IReadOnlyDictionary rawData) => + Price.FromRawUnchecked(rawData); +} + +/// +/// The license allocation price to add to the plan. +/// +[JsonConverter(typeof(LicenseAllocationPriceConverter))] +public record class LicenseAllocationPrice : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public string ItemID + { + get + { + return Match( + unit: (x) => x.ItemID, + tiered: (x) => x.ItemID, + bulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + package: (x) => x.ItemID, + matrix: (x) => x.ItemID, + thresholdTotalAmount: (x) => x.ItemID, + tieredPackage: (x) => x.ItemID, + tieredWithMinimum: (x) => x.ItemID, + groupedTiered: (x) => x.ItemID, + tieredPackageWithMinimum: (x) => x.ItemID, + packageWithAllocation: (x) => x.ItemID, + unitWithPercent: (x) => x.ItemID, + matrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + unitWithProration: (x) => x.ItemID, + groupedAllocation: (x) => x.ItemID, + bulkWithProration: (x) => x.ItemID, + groupedWithProratedMinimum: (x) => x.ItemID, + groupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + matrixWithDisplayName: (x) => x.ItemID, + groupedTieredPackage: (x) => x.ItemID, + maxGroupTieredPackage: (x) => x.ItemID, + scalableMatrixWithUnitPricing: (x) => x.ItemID, + scalableMatrixWithTieredPricing: (x) => x.ItemID, + cumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + minimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } + } + + public JsonElement ModelType + { + get + { + return Match( + unit: (x) => x.ModelType, + tiered: (x) => x.ModelType, + bulk: (x) => x.ModelType, + bulkWithFilters: (x) => x.ModelType, + package: (x) => x.ModelType, + matrix: (x) => x.ModelType, + thresholdTotalAmount: (x) => x.ModelType, + tieredPackage: (x) => x.ModelType, + tieredWithMinimum: (x) => x.ModelType, + groupedTiered: (x) => x.ModelType, + tieredPackageWithMinimum: (x) => x.ModelType, + packageWithAllocation: (x) => x.ModelType, + unitWithPercent: (x) => x.ModelType, + matrixWithAllocation: (x) => x.ModelType, + tieredWithProration: (x) => x.ModelType, + unitWithProration: (x) => x.ModelType, + groupedAllocation: (x) => x.ModelType, + bulkWithProration: (x) => x.ModelType, + groupedWithProratedMinimum: (x) => x.ModelType, + groupedWithMeteredMinimum: (x) => x.ModelType, + groupedWithMinMaxThresholds: (x) => x.ModelType, + matrixWithDisplayName: (x) => x.ModelType, + groupedTieredPackage: (x) => x.ModelType, + maxGroupTieredPackage: (x) => x.ModelType, + scalableMatrixWithUnitPricing: (x) => x.ModelType, + scalableMatrixWithTieredPricing: (x) => x.ModelType, + cumulativeGroupedBulk: (x) => x.ModelType, + cumulativeGroupedAllocation: (x) => x.ModelType, + minimumComposite: (x) => x.ModelType, + percent: (x) => x.ModelType, + eventOutput: (x) => x.ModelType + ); + } + } + + public string Name + { + get + { + return Match( + unit: (x) => x.Name, + tiered: (x) => x.Name, + bulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + package: (x) => x.Name, + matrix: (x) => x.Name, + thresholdTotalAmount: (x) => x.Name, + tieredPackage: (x) => x.Name, + tieredWithMinimum: (x) => x.Name, + groupedTiered: (x) => x.Name, + tieredPackageWithMinimum: (x) => x.Name, + packageWithAllocation: (x) => x.Name, + unitWithPercent: (x) => x.Name, + matrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + unitWithProration: (x) => x.Name, + groupedAllocation: (x) => x.Name, + bulkWithProration: (x) => x.Name, + groupedWithProratedMinimum: (x) => x.Name, + groupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + matrixWithDisplayName: (x) => x.Name, + groupedTieredPackage: (x) => x.Name, + maxGroupTieredPackage: (x) => x.Name, + scalableMatrixWithUnitPricing: (x) => x.Name, + scalableMatrixWithTieredPricing: (x) => x.Name, + cumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + minimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } + } + + public string? BillableMetricID + { + get + { + return Match( + unit: (x) => x.BillableMetricID, + tiered: (x) => x.BillableMetricID, + bulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + package: (x) => x.BillableMetricID, + matrix: (x) => x.BillableMetricID, + thresholdTotalAmount: (x) => x.BillableMetricID, + tieredPackage: (x) => x.BillableMetricID, + tieredWithMinimum: (x) => x.BillableMetricID, + groupedTiered: (x) => x.BillableMetricID, + tieredPackageWithMinimum: (x) => x.BillableMetricID, + packageWithAllocation: (x) => x.BillableMetricID, + unitWithPercent: (x) => x.BillableMetricID, + matrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + unitWithProration: (x) => x.BillableMetricID, + groupedAllocation: (x) => x.BillableMetricID, + bulkWithProration: (x) => x.BillableMetricID, + groupedWithProratedMinimum: (x) => x.BillableMetricID, + groupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + matrixWithDisplayName: (x) => x.BillableMetricID, + groupedTieredPackage: (x) => x.BillableMetricID, + maxGroupTieredPackage: (x) => x.BillableMetricID, + scalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + scalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + cumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + minimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } + } + + public bool? BilledInAdvance + { + get + { + return Match( + unit: (x) => x.BilledInAdvance, + tiered: (x) => x.BilledInAdvance, + bulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + package: (x) => x.BilledInAdvance, + matrix: (x) => x.BilledInAdvance, + thresholdTotalAmount: (x) => x.BilledInAdvance, + tieredPackage: (x) => x.BilledInAdvance, + tieredWithMinimum: (x) => x.BilledInAdvance, + groupedTiered: (x) => x.BilledInAdvance, + tieredPackageWithMinimum: (x) => x.BilledInAdvance, + packageWithAllocation: (x) => x.BilledInAdvance, + unitWithPercent: (x) => x.BilledInAdvance, + matrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + unitWithProration: (x) => x.BilledInAdvance, + groupedAllocation: (x) => x.BilledInAdvance, + bulkWithProration: (x) => x.BilledInAdvance, + groupedWithProratedMinimum: (x) => x.BilledInAdvance, + groupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + matrixWithDisplayName: (x) => x.BilledInAdvance, + groupedTieredPackage: (x) => x.BilledInAdvance, + maxGroupTieredPackage: (x) => x.BilledInAdvance, + scalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + scalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + cumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + minimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } + } + + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + return Match( + unit: (x) => x.BillingCycleConfiguration, + tiered: (x) => x.BillingCycleConfiguration, + bulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + package: (x) => x.BillingCycleConfiguration, + matrix: (x) => x.BillingCycleConfiguration, + thresholdTotalAmount: (x) => x.BillingCycleConfiguration, + tieredPackage: (x) => x.BillingCycleConfiguration, + tieredWithMinimum: (x) => x.BillingCycleConfiguration, + groupedTiered: (x) => x.BillingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + packageWithAllocation: (x) => x.BillingCycleConfiguration, + unitWithPercent: (x) => x.BillingCycleConfiguration, + matrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + unitWithProration: (x) => x.BillingCycleConfiguration, + groupedAllocation: (x) => x.BillingCycleConfiguration, + bulkWithProration: (x) => x.BillingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + matrixWithDisplayName: (x) => x.BillingCycleConfiguration, + groupedTieredPackage: (x) => x.BillingCycleConfiguration, + maxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + minimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } + } + + public double? ConversionRate + { + get + { + return Match( + unit: (x) => x.ConversionRate, + tiered: (x) => x.ConversionRate, + bulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + package: (x) => x.ConversionRate, + matrix: (x) => x.ConversionRate, + thresholdTotalAmount: (x) => x.ConversionRate, + tieredPackage: (x) => x.ConversionRate, + tieredWithMinimum: (x) => x.ConversionRate, + groupedTiered: (x) => x.ConversionRate, + tieredPackageWithMinimum: (x) => x.ConversionRate, + packageWithAllocation: (x) => x.ConversionRate, + unitWithPercent: (x) => x.ConversionRate, + matrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + unitWithProration: (x) => x.ConversionRate, + groupedAllocation: (x) => x.ConversionRate, + bulkWithProration: (x) => x.ConversionRate, + groupedWithProratedMinimum: (x) => x.ConversionRate, + groupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + matrixWithDisplayName: (x) => x.ConversionRate, + groupedTieredPackage: (x) => x.ConversionRate, + maxGroupTieredPackage: (x) => x.ConversionRate, + scalableMatrixWithUnitPricing: (x) => x.ConversionRate, + scalableMatrixWithTieredPricing: (x) => x.ConversionRate, + cumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + minimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } + } + + public string? Currency + { + get + { + return Match( + unit: (x) => x.Currency, + tiered: (x) => x.Currency, + bulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + package: (x) => x.Currency, + matrix: (x) => x.Currency, + thresholdTotalAmount: (x) => x.Currency, + tieredPackage: (x) => x.Currency, + tieredWithMinimum: (x) => x.Currency, + groupedTiered: (x) => x.Currency, + tieredPackageWithMinimum: (x) => x.Currency, + packageWithAllocation: (x) => x.Currency, + unitWithPercent: (x) => x.Currency, + matrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + unitWithProration: (x) => x.Currency, + groupedAllocation: (x) => x.Currency, + bulkWithProration: (x) => x.Currency, + groupedWithProratedMinimum: (x) => x.Currency, + groupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + matrixWithDisplayName: (x) => x.Currency, + groupedTieredPackage: (x) => x.Currency, + maxGroupTieredPackage: (x) => x.Currency, + scalableMatrixWithUnitPricing: (x) => x.Currency, + scalableMatrixWithTieredPricing: (x) => x.Currency, + cumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + minimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } + } + + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + return Match( + unit: (x) => x.DimensionalPriceConfiguration, + tiered: (x) => x.DimensionalPriceConfiguration, + bulk: (x) => x.DimensionalPriceConfiguration, + bulkWithFilters: (x) => x.DimensionalPriceConfiguration, + package: (x) => x.DimensionalPriceConfiguration, + matrix: (x) => x.DimensionalPriceConfiguration, + thresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + tieredPackage: (x) => x.DimensionalPriceConfiguration, + tieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + groupedTiered: (x) => x.DimensionalPriceConfiguration, + tieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + packageWithAllocation: (x) => x.DimensionalPriceConfiguration, + unitWithPercent: (x) => x.DimensionalPriceConfiguration, + matrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + tieredWithProration: (x) => x.DimensionalPriceConfiguration, + unitWithProration: (x) => x.DimensionalPriceConfiguration, + groupedAllocation: (x) => x.DimensionalPriceConfiguration, + bulkWithProration: (x) => x.DimensionalPriceConfiguration, + groupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, + matrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + groupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + maxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, + scalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + minimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } + } + + public string? ExternalPriceID + { + get + { + return Match( + unit: (x) => x.ExternalPriceID, + tiered: (x) => x.ExternalPriceID, + bulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + package: (x) => x.ExternalPriceID, + matrix: (x) => x.ExternalPriceID, + thresholdTotalAmount: (x) => x.ExternalPriceID, + tieredPackage: (x) => x.ExternalPriceID, + tieredWithMinimum: (x) => x.ExternalPriceID, + groupedTiered: (x) => x.ExternalPriceID, + tieredPackageWithMinimum: (x) => x.ExternalPriceID, + packageWithAllocation: (x) => x.ExternalPriceID, + unitWithPercent: (x) => x.ExternalPriceID, + matrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + unitWithProration: (x) => x.ExternalPriceID, + groupedAllocation: (x) => x.ExternalPriceID, + bulkWithProration: (x) => x.ExternalPriceID, + groupedWithProratedMinimum: (x) => x.ExternalPriceID, + groupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + matrixWithDisplayName: (x) => x.ExternalPriceID, + groupedTieredPackage: (x) => x.ExternalPriceID, + maxGroupTieredPackage: (x) => x.ExternalPriceID, + scalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + scalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + cumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + minimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } + } + + public double? FixedPriceQuantity + { + get + { + return Match( + unit: (x) => x.FixedPriceQuantity, + tiered: (x) => x.FixedPriceQuantity, + bulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + package: (x) => x.FixedPriceQuantity, + matrix: (x) => x.FixedPriceQuantity, + thresholdTotalAmount: (x) => x.FixedPriceQuantity, + tieredPackage: (x) => x.FixedPriceQuantity, + tieredWithMinimum: (x) => x.FixedPriceQuantity, + groupedTiered: (x) => x.FixedPriceQuantity, + tieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + packageWithAllocation: (x) => x.FixedPriceQuantity, + unitWithPercent: (x) => x.FixedPriceQuantity, + matrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + unitWithProration: (x) => x.FixedPriceQuantity, + groupedAllocation: (x) => x.FixedPriceQuantity, + bulkWithProration: (x) => x.FixedPriceQuantity, + groupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + groupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + matrixWithDisplayName: (x) => x.FixedPriceQuantity, + groupedTieredPackage: (x) => x.FixedPriceQuantity, + maxGroupTieredPackage: (x) => x.FixedPriceQuantity, + scalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + scalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + cumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + minimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } + } + + public string? InvoiceGroupingKey + { + get + { + return Match( + unit: (x) => x.InvoiceGroupingKey, + tiered: (x) => x.InvoiceGroupingKey, + bulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + package: (x) => x.InvoiceGroupingKey, + matrix: (x) => x.InvoiceGroupingKey, + thresholdTotalAmount: (x) => x.InvoiceGroupingKey, + tieredPackage: (x) => x.InvoiceGroupingKey, + tieredWithMinimum: (x) => x.InvoiceGroupingKey, + groupedTiered: (x) => x.InvoiceGroupingKey, + tieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + packageWithAllocation: (x) => x.InvoiceGroupingKey, + unitWithPercent: (x) => x.InvoiceGroupingKey, + matrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + unitWithProration: (x) => x.InvoiceGroupingKey, + groupedAllocation: (x) => x.InvoiceGroupingKey, + bulkWithProration: (x) => x.InvoiceGroupingKey, + groupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + matrixWithDisplayName: (x) => x.InvoiceGroupingKey, + groupedTieredPackage: (x) => x.InvoiceGroupingKey, + maxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + scalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + scalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + cumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } + } + + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + return Match( + unit: (x) => x.InvoicingCycleConfiguration, + tiered: (x) => x.InvoicingCycleConfiguration, + bulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + package: (x) => x.InvoicingCycleConfiguration, + matrix: (x) => x.InvoicingCycleConfiguration, + thresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + tieredPackage: (x) => x.InvoicingCycleConfiguration, + tieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + groupedTiered: (x) => x.InvoicingCycleConfiguration, + tieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + packageWithAllocation: (x) => x.InvoicingCycleConfiguration, + unitWithPercent: (x) => x.InvoicingCycleConfiguration, + matrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + unitWithProration: (x) => x.InvoicingCycleConfiguration, + groupedAllocation: (x) => x.InvoicingCycleConfiguration, + bulkWithProration: (x) => x.InvoicingCycleConfiguration, + groupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + matrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + groupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + maxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + scalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + minimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } + } + + public string? LicenseTypeID + { + get + { + return Match( + unit: (x) => x.LicenseTypeID, + tiered: (x) => x.LicenseTypeID, + bulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + package: (x) => x.LicenseTypeID, + matrix: (x) => x.LicenseTypeID, + thresholdTotalAmount: (x) => x.LicenseTypeID, + tieredPackage: (x) => x.LicenseTypeID, + tieredWithMinimum: (x) => x.LicenseTypeID, + groupedTiered: (x) => x.LicenseTypeID, + tieredPackageWithMinimum: (x) => x.LicenseTypeID, + packageWithAllocation: (x) => x.LicenseTypeID, + unitWithPercent: (x) => x.LicenseTypeID, + matrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + unitWithProration: (x) => x.LicenseTypeID, + groupedAllocation: (x) => x.LicenseTypeID, + bulkWithProration: (x) => x.LicenseTypeID, + groupedWithProratedMinimum: (x) => x.LicenseTypeID, + groupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + matrixWithDisplayName: (x) => x.LicenseTypeID, + groupedTieredPackage: (x) => x.LicenseTypeID, + maxGroupTieredPackage: (x) => x.LicenseTypeID, + scalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + scalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + cumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + minimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + + public string? ReferenceID + { + get + { + return Match( + unit: (x) => x.ReferenceID, + tiered: (x) => x.ReferenceID, + bulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + package: (x) => x.ReferenceID, + matrix: (x) => x.ReferenceID, + thresholdTotalAmount: (x) => x.ReferenceID, + tieredPackage: (x) => x.ReferenceID, + tieredWithMinimum: (x) => x.ReferenceID, + groupedTiered: (x) => x.ReferenceID, + tieredPackageWithMinimum: (x) => x.ReferenceID, + packageWithAllocation: (x) => x.ReferenceID, + unitWithPercent: (x) => x.ReferenceID, + matrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + unitWithProration: (x) => x.ReferenceID, + groupedAllocation: (x) => x.ReferenceID, + bulkWithProration: (x) => x.ReferenceID, + groupedWithProratedMinimum: (x) => x.ReferenceID, + groupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + matrixWithDisplayName: (x) => x.ReferenceID, + groupedTieredPackage: (x) => x.ReferenceID, + maxGroupTieredPackage: (x) => x.ReferenceID, + scalableMatrixWithUnitPricing: (x) => x.ReferenceID, + scalableMatrixWithTieredPricing: (x) => x.ReferenceID, + cumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + minimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } + } + + public LicenseAllocationPrice(Unit value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(Tiered value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(Bulk value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(BulkWithFilters value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(Package value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(Matrix value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(ThresholdTotalAmount value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(TieredPackage value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(TieredWithMinimum value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(GroupedTiered value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(TieredPackageWithMinimum value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(PackageWithAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(UnitWithPercent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(MatrixWithAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(TieredWithProration value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(UnitWithProration value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(GroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(BulkWithProration value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(GroupedWithProratedMinimum value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(GroupedWithMeteredMinimum value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(GroupedWithMinMaxThresholds value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(MatrixWithDisplayName value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(GroupedTieredPackage value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(MaxGroupTieredPackage value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(ScalableMatrixWithUnitPricing value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice( + ScalableMatrixWithTieredPricing value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(CumulativeGroupedBulk value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(CumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(MinimumComposite value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(Percent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(EventOutput value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public LicenseAllocationPrice(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 `Unit` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out Unit? value) + { + value = this.Value as Unit; + 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 `Tiered` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out Tiered? value) + { + value = this.Value as Tiered; + 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.TryPickBulk(out var value)) { + /// // `value` is of type `Bulk` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulk([NotNullWhen(true)] out Bulk? value) + { + value = this.Value as Bulk; + 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `BulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) + { + value = this.Value as BulkWithFilters; + 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.TryPickPackage(out var value)) { + /// // `value` is of type `Package` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPackage([NotNullWhen(true)] out Package? value) + { + value = this.Value as Package; + 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.TryPickMatrix(out var value)) { + /// // `value` is of type `Matrix` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrix([NotNullWhen(true)] out Matrix? value) + { + value = this.Value as Matrix; + 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.TryPickThresholdTotalAmount(out var value)) { + /// // `value` is of type `ThresholdTotalAmount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickThresholdTotalAmount([NotNullWhen(true)] out ThresholdTotalAmount? value) + { + value = this.Value as ThresholdTotalAmount; + 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.TryPickTieredPackage(out var value)) { + /// // `value` is of type `TieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredPackage([NotNullWhen(true)] out TieredPackage? value) + { + value = this.Value as TieredPackage; + 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.TryPickTieredWithMinimum(out var value)) { + /// // `value` is of type `TieredWithMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithMinimum([NotNullWhen(true)] out TieredWithMinimum? value) + { + value = this.Value as TieredWithMinimum; + 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.TryPickGroupedTiered(out var value)) { + /// // `value` is of type `GroupedTiered` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedTiered([NotNullWhen(true)] out GroupedTiered? value) + { + value = this.Value as GroupedTiered; + 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.TryPickTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `TieredPackageWithMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredPackageWithMinimum( + [NotNullWhen(true)] out TieredPackageWithMinimum? value + ) + { + value = this.Value as TieredPackageWithMinimum; + 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.TryPickPackageWithAllocation(out var value)) { + /// // `value` is of type `PackageWithAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPackageWithAllocation([NotNullWhen(true)] out PackageWithAllocation? value) + { + value = this.Value as PackageWithAllocation; + 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.TryPickUnitWithPercent(out var value)) { + /// // `value` is of type `UnitWithPercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnitWithPercent([NotNullWhen(true)] out UnitWithPercent? value) + { + value = this.Value as UnitWithPercent; + 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.TryPickMatrixWithAllocation(out var value)) { + /// // `value` is of type `MatrixWithAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithAllocation([NotNullWhen(true)] out MatrixWithAllocation? value) + { + value = this.Value as MatrixWithAllocation; + 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.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `TieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) + { + value = this.Value as TieredWithProration; + 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.TryPickUnitWithProration(out var value)) { + /// // `value` is of type `UnitWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnitWithProration([NotNullWhen(true)] out UnitWithProration? value) + { + value = this.Value as UnitWithProration; + 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.TryPickGroupedAllocation(out var value)) { + /// // `value` is of type `GroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedAllocation([NotNullWhen(true)] out GroupedAllocation? value) + { + value = this.Value as GroupedAllocation; + 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.TryPickBulkWithProration(out var value)) { + /// // `value` is of type `BulkWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithProration([NotNullWhen(true)] out BulkWithProration? value) + { + value = this.Value as BulkWithProration; + 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.TryPickGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `GroupedWithProratedMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithProratedMinimum( + [NotNullWhen(true)] out GroupedWithProratedMinimum? value + ) + { + value = this.Value as GroupedWithProratedMinimum; + 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.TryPickGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `GroupedWithMeteredMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMeteredMinimum( + [NotNullWhen(true)] out GroupedWithMeteredMinimum? value + ) + { + value = this.Value as GroupedWithMeteredMinimum; + 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.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `GroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value + ) + { + value = this.Value as GroupedWithMinMaxThresholds; + 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.TryPickMatrixWithDisplayName(out var value)) { + /// // `value` is of type `MatrixWithDisplayName` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithDisplayName([NotNullWhen(true)] out MatrixWithDisplayName? value) + { + value = this.Value as MatrixWithDisplayName; + 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.TryPickGroupedTieredPackage(out var value)) { + /// // `value` is of type `GroupedTieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedTieredPackage([NotNullWhen(true)] out GroupedTieredPackage? value) + { + value = this.Value as GroupedTieredPackage; + 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.TryPickMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `MaxGroupTieredPackage` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMaxGroupTieredPackage([NotNullWhen(true)] out MaxGroupTieredPackage? value) + { + value = this.Value as MaxGroupTieredPackage; + 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.TryPickScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `ScalableMatrixWithUnitPricing` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out ScalableMatrixWithUnitPricing? value + ) + { + value = this.Value as ScalableMatrixWithUnitPricing; + 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.TryPickScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `ScalableMatrixWithTieredPricing` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out ScalableMatrixWithTieredPricing? value + ) + { + value = this.Value as ScalableMatrixWithTieredPricing; + 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.TryPickCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `CumulativeGroupedBulk` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedBulk([NotNullWhen(true)] out CumulativeGroupedBulk? value) + { + value = this.Value as CumulativeGroupedBulk; + 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 `CumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out CumulativeGroupedAllocation? value + ) + { + value = this.Value as 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.TryPickMinimumComposite(out var value)) { + /// // `value` is of type `MinimumComposite` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMinimumComposite([NotNullWhen(true)] out MinimumComposite? value) + { + value = this.Value as MinimumComposite; + 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 `Percent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) + { + 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 . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `EventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) + { + value = this.Value as EventOutput; + 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( + /// (Unit value) => {...}, + /// (Tiered value) => {...}, + /// (Bulk value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (Package value) => {...}, + /// (Matrix value) => {...}, + /// (ThresholdTotalAmount value) => {...}, + /// (TieredPackage value) => {...}, + /// (TieredWithMinimum value) => {...}, + /// (GroupedTiered value) => {...}, + /// (TieredPackageWithMinimum value) => {...}, + /// (PackageWithAllocation value) => {...}, + /// (UnitWithPercent value) => {...}, + /// (MatrixWithAllocation value) => {...}, + /// (TieredWithProration value) => {...}, + /// (UnitWithProration value) => {...}, + /// (GroupedAllocation value) => {...}, + /// (BulkWithProration value) => {...}, + /// (GroupedWithProratedMinimum value) => {...}, + /// (GroupedWithMeteredMinimum value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (MatrixWithDisplayName value) => {...}, + /// (GroupedTieredPackage value) => {...}, + /// (MaxGroupTieredPackage value) => {...}, + /// (ScalableMatrixWithUnitPricing value) => {...}, + /// (ScalableMatrixWithTieredPricing value) => {...}, + /// (CumulativeGroupedBulk value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (MinimumComposite value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered, + System::Action bulk, + System::Action bulkWithFilters, + System::Action package, + System::Action matrix, + System::Action thresholdTotalAmount, + System::Action tieredPackage, + System::Action tieredWithMinimum, + System::Action groupedTiered, + System::Action tieredPackageWithMinimum, + System::Action packageWithAllocation, + System::Action unitWithPercent, + System::Action matrixWithAllocation, + System::Action tieredWithProration, + System::Action unitWithProration, + System::Action groupedAllocation, + System::Action bulkWithProration, + System::Action groupedWithProratedMinimum, + System::Action groupedWithMeteredMinimum, + System::Action groupedWithMinMaxThresholds, + System::Action matrixWithDisplayName, + System::Action groupedTieredPackage, + System::Action maxGroupTieredPackage, + System::Action scalableMatrixWithUnitPricing, + System::Action scalableMatrixWithTieredPricing, + System::Action cumulativeGroupedBulk, + System::Action cumulativeGroupedAllocation, + System::Action minimumComposite, + System::Action percent, + System::Action eventOutput + ) + { + switch (this.Value) + { + case Unit value: + unit(value); + break; + case Tiered value: + tiered(value); + break; + case Bulk value: + bulk(value); + break; + case BulkWithFilters value: + bulkWithFilters(value); + break; + case Package value: + package(value); + break; + case Matrix value: + matrix(value); + break; + case ThresholdTotalAmount value: + thresholdTotalAmount(value); + break; + case TieredPackage value: + tieredPackage(value); + break; + case TieredWithMinimum value: + tieredWithMinimum(value); + break; + case GroupedTiered value: + groupedTiered(value); + break; + case TieredPackageWithMinimum value: + tieredPackageWithMinimum(value); + break; + case PackageWithAllocation value: + packageWithAllocation(value); + break; + case UnitWithPercent value: + unitWithPercent(value); + break; + case MatrixWithAllocation value: + matrixWithAllocation(value); + break; + case TieredWithProration value: + tieredWithProration(value); + break; + case UnitWithProration value: + unitWithProration(value); + break; + case GroupedAllocation value: + groupedAllocation(value); + break; + case BulkWithProration value: + bulkWithProration(value); + break; + case GroupedWithProratedMinimum value: + groupedWithProratedMinimum(value); + break; + case GroupedWithMeteredMinimum value: + groupedWithMeteredMinimum(value); + break; + case GroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case MatrixWithDisplayName value: + matrixWithDisplayName(value); + break; + case GroupedTieredPackage value: + groupedTieredPackage(value); + break; + case MaxGroupTieredPackage value: + maxGroupTieredPackage(value); + break; + case ScalableMatrixWithUnitPricing value: + scalableMatrixWithUnitPricing(value); + break; + case ScalableMatrixWithTieredPricing value: + scalableMatrixWithTieredPricing(value); + break; + case CumulativeGroupedBulk value: + cumulativeGroupedBulk(value); + break; + case CumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case MinimumComposite value: + minimumComposite(value); + break; + case Percent value: + percent(value); + break; + case EventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ); + } + } + + /// + /// 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( + /// (Unit value) => {...}, + /// (Tiered value) => {...}, + /// (Bulk value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (Package value) => {...}, + /// (Matrix value) => {...}, + /// (ThresholdTotalAmount value) => {...}, + /// (TieredPackage value) => {...}, + /// (TieredWithMinimum value) => {...}, + /// (GroupedTiered value) => {...}, + /// (TieredPackageWithMinimum value) => {...}, + /// (PackageWithAllocation value) => {...}, + /// (UnitWithPercent value) => {...}, + /// (MatrixWithAllocation value) => {...}, + /// (TieredWithProration value) => {...}, + /// (UnitWithProration value) => {...}, + /// (GroupedAllocation value) => {...}, + /// (BulkWithProration value) => {...}, + /// (GroupedWithProratedMinimum value) => {...}, + /// (GroupedWithMeteredMinimum value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (MatrixWithDisplayName value) => {...}, + /// (GroupedTieredPackage value) => {...}, + /// (MaxGroupTieredPackage value) => {...}, + /// (ScalableMatrixWithUnitPricing value) => {...}, + /// (ScalableMatrixWithTieredPricing value) => {...}, + /// (CumulativeGroupedBulk value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (MinimumComposite value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered, + System::Func bulk, + System::Func bulkWithFilters, + System::Func package, + System::Func matrix, + System::Func thresholdTotalAmount, + System::Func tieredPackage, + System::Func tieredWithMinimum, + System::Func groupedTiered, + System::Func tieredPackageWithMinimum, + System::Func packageWithAllocation, + System::Func unitWithPercent, + System::Func matrixWithAllocation, + System::Func tieredWithProration, + System::Func unitWithProration, + System::Func groupedAllocation, + System::Func bulkWithProration, + System::Func groupedWithProratedMinimum, + System::Func groupedWithMeteredMinimum, + System::Func groupedWithMinMaxThresholds, + System::Func matrixWithDisplayName, + System::Func groupedTieredPackage, + System::Func maxGroupTieredPackage, + System::Func scalableMatrixWithUnitPricing, + System::Func scalableMatrixWithTieredPricing, + System::Func cumulativeGroupedBulk, + System::Func cumulativeGroupedAllocation, + System::Func minimumComposite, + System::Func percent, + System::Func eventOutput + ) + { + return this.Value switch + { + Unit value => unit(value), + Tiered value => tiered(value), + Bulk value => bulk(value), + BulkWithFilters value => bulkWithFilters(value), + Package value => package(value), + Matrix value => matrix(value), + ThresholdTotalAmount value => thresholdTotalAmount(value), + TieredPackage value => tieredPackage(value), + TieredWithMinimum value => tieredWithMinimum(value), + GroupedTiered value => groupedTiered(value), + TieredPackageWithMinimum value => tieredPackageWithMinimum(value), + PackageWithAllocation value => packageWithAllocation(value), + UnitWithPercent value => unitWithPercent(value), + MatrixWithAllocation value => matrixWithAllocation(value), + TieredWithProration value => tieredWithProration(value), + UnitWithProration value => unitWithProration(value), + GroupedAllocation value => groupedAllocation(value), + BulkWithProration value => bulkWithProration(value), + GroupedWithProratedMinimum value => groupedWithProratedMinimum(value), + GroupedWithMeteredMinimum value => groupedWithMeteredMinimum(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), + MatrixWithDisplayName value => matrixWithDisplayName(value), + GroupedTieredPackage value => groupedTieredPackage(value), + MaxGroupTieredPackage value => maxGroupTieredPackage(value), + ScalableMatrixWithUnitPricing value => scalableMatrixWithUnitPricing(value), + ScalableMatrixWithTieredPricing value => scalableMatrixWithTieredPricing(value), + CumulativeGroupedBulk value => cumulativeGroupedBulk(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), + MinimumComposite value => minimumComposite(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ), + }; + } + + public static implicit operator LicenseAllocationPrice(Unit value) => new(value); + + public static implicit operator LicenseAllocationPrice(Tiered value) => new(value); + + public static implicit operator LicenseAllocationPrice(Bulk value) => new(value); + + public static implicit operator LicenseAllocationPrice(BulkWithFilters value) => new(value); + + public static implicit operator LicenseAllocationPrice(Package value) => new(value); + + public static implicit operator LicenseAllocationPrice(Matrix value) => new(value); + + public static implicit operator LicenseAllocationPrice(ThresholdTotalAmount value) => + new(value); + + public static implicit operator LicenseAllocationPrice(TieredPackage value) => new(value); + + public static implicit operator LicenseAllocationPrice(TieredWithMinimum value) => new(value); + + public static implicit operator LicenseAllocationPrice(GroupedTiered value) => new(value); + + public static implicit operator LicenseAllocationPrice(TieredPackageWithMinimum value) => + new(value); + + public static implicit operator LicenseAllocationPrice(PackageWithAllocation value) => + new(value); + + public static implicit operator LicenseAllocationPrice(UnitWithPercent value) => new(value); + + public static implicit operator LicenseAllocationPrice(MatrixWithAllocation value) => + new(value); + + public static implicit operator LicenseAllocationPrice(TieredWithProration value) => new(value); + + public static implicit operator LicenseAllocationPrice(UnitWithProration value) => new(value); + + public static implicit operator LicenseAllocationPrice(GroupedAllocation value) => new(value); + + public static implicit operator LicenseAllocationPrice(BulkWithProration value) => new(value); + + public static implicit operator LicenseAllocationPrice(GroupedWithProratedMinimum value) => + new(value); + + public static implicit operator LicenseAllocationPrice(GroupedWithMeteredMinimum value) => + new(value); + + public static implicit operator LicenseAllocationPrice(GroupedWithMinMaxThresholds value) => + new(value); + + public static implicit operator LicenseAllocationPrice(MatrixWithDisplayName value) => + new(value); + + public static implicit operator LicenseAllocationPrice(GroupedTieredPackage value) => + new(value); + + public static implicit operator LicenseAllocationPrice(MaxGroupTieredPackage value) => + new(value); + + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithUnitPricing value) => + new(value); + + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithTieredPricing value) => + new(value); + + public static implicit operator LicenseAllocationPrice(CumulativeGroupedBulk value) => + new(value); + + public static implicit operator LicenseAllocationPrice(CumulativeGroupedAllocation value) => + new(value); + + public static implicit operator LicenseAllocationPrice(MinimumComposite value) => new(value); + + public static implicit operator LicenseAllocationPrice(Percent value) => new(value); + + public static implicit operator LicenseAllocationPrice(EventOutput 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 LicenseAllocationPrice" + ); + } + this.Switch( + (unit) => unit.Validate(), + (tiered) => tiered.Validate(), + (bulk) => bulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (package) => package.Validate(), + (matrix) => matrix.Validate(), + (thresholdTotalAmount) => thresholdTotalAmount.Validate(), + (tieredPackage) => tieredPackage.Validate(), + (tieredWithMinimum) => tieredWithMinimum.Validate(), + (groupedTiered) => groupedTiered.Validate(), + (tieredPackageWithMinimum) => tieredPackageWithMinimum.Validate(), + (packageWithAllocation) => packageWithAllocation.Validate(), + (unitWithPercent) => unitWithPercent.Validate(), + (matrixWithAllocation) => matrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (unitWithProration) => unitWithProration.Validate(), + (groupedAllocation) => groupedAllocation.Validate(), + (bulkWithProration) => bulkWithProration.Validate(), + (groupedWithProratedMinimum) => groupedWithProratedMinimum.Validate(), + (groupedWithMeteredMinimum) => groupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (matrixWithDisplayName) => matrixWithDisplayName.Validate(), + (groupedTieredPackage) => groupedTieredPackage.Validate(), + (maxGroupTieredPackage) => maxGroupTieredPackage.Validate(), + (scalableMatrixWithUnitPricing) => scalableMatrixWithUnitPricing.Validate(), + (scalableMatrixWithTieredPricing) => scalableMatrixWithTieredPricing.Validate(), + (cumulativeGroupedBulk) => cumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (minimumComposite) => minimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); + } + + public virtual bool Equals(LicenseAllocationPrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Unit _ => 0, + Tiered _ => 1, + Bulk _ => 2, + BulkWithFilters _ => 3, + Package _ => 4, + Matrix _ => 5, + ThresholdTotalAmount _ => 6, + TieredPackage _ => 7, + TieredWithMinimum _ => 8, + GroupedTiered _ => 9, + TieredPackageWithMinimum _ => 10, + PackageWithAllocation _ => 11, + UnitWithPercent _ => 12, + MatrixWithAllocation _ => 13, + TieredWithProration _ => 14, + UnitWithProration _ => 15, + GroupedAllocation _ => 16, + BulkWithProration _ => 17, + GroupedWithProratedMinimum _ => 18, + GroupedWithMeteredMinimum _ => 19, + GroupedWithMinMaxThresholds _ => 20, + MatrixWithDisplayName _ => 21, + GroupedTieredPackage _ => 22, + MaxGroupTieredPackage _ => 23, + ScalableMatrixWithUnitPricing _ => 24, + ScalableMatrixWithTieredPricing _ => 25, + CumulativeGroupedBulk _ => 26, + CumulativeGroupedAllocation _ => 27, + MinimumComposite _ => 28, + Percent _ => 29, + EventOutput _ => 30, + _ => -1, + }; + } +} + +sealed class LicenseAllocationPriceConverter : JsonConverter +{ + public override LicenseAllocationPrice? 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_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 LicenseAllocationPrice(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + LicenseAllocationPrice? value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value?.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Unit : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 unit pricing + /// + public required UnitConfig UnitConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_config"); + } + init { this._rawData.Set("unit_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 ConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("unit"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public Unit() + { + this.ModelType = JsonSerializer.SerializeToElement("unit"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Unit(Unit unit) + : base(unit) { } +#pragma warning restore CS8618 + + public Unit(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Unit(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Unit FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitFromRaw : IFromRawJson +{ + /// + public Unit FromRawUnchecked(IReadOnlyDictionary rawData) => + Unit.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CadenceConverter))] +public enum Cadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, Cadence value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public LicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocation(LicenseAllocation licenseAllocation) + : base(licenseAllocation) { } +#pragma warning restore CS8618 + + public LicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseAllocationFromRaw : IFromRawJson +{ + /// + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ConversionRateConfigConverter))] +public record class ConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ConversionRateConfig(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 ConversionRateConfig" + ); + } + } + + /// + /// 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 ConversionRateConfig" + ), + }; + } + + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig 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 + /// (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 ConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ConversionRateConfigConverter : JsonConverter +{ + public override ConversionRateConfig? 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 ConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Tiered : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered pricing + /// + public required TieredConfig TieredConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tiered_config"); + } + init { this._rawData.Set("tiered_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 TieredConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("tiered"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public Tiered() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Tiered(Tiered tiered) + : base(tiered) { } +#pragma warning restore CS8618 + + public Tiered(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Tiered(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Tiered FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredFromRaw : IFromRawJson +{ + /// + public Tiered FromRawUnchecked(IReadOnlyDictionary rawData) => + Tiered.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredCadenceConverter))] +public enum TieredCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredCadenceConverter : JsonConverter +{ + public override TieredCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredCadence.Annual, + "semi_annual" => TieredCadence.SemiAnnual, + "monthly" => TieredCadence.Monthly, + "quarterly" => TieredCadence.Quarterly, + "one_time" => TieredCadence.OneTime, + "custom" => TieredCadence.Custom, + _ => (TieredCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredCadence.Annual => "annual", + TieredCadence.SemiAnnual => "semi_annual", + TieredCadence.Monthly => "monthly", + TieredCadence.Quarterly => "quarterly", + TieredCadence.OneTime => "one_time", + TieredCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredLicenseAllocation(TieredLicenseAllocation tieredLicenseAllocation) + : base(tieredLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredLicenseAllocationFromRaw : IFromRawJson +{ + /// + public TieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredConversionRateConfigConverter))] +public record class TieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredConversionRateConfig(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 TieredConversionRateConfig" + ); + } + } + + /// + /// 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 TieredConversionRateConfig" + ), + }; + } + + public static implicit operator TieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredConversionRateConfig( + 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 TieredConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredConversionRateConfigConverter : JsonConverter +{ + public override TieredConversionRateConfig? 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 TieredConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Bulk : JsonModel +{ + /// + /// Configuration for bulk pricing + /// + public required BulkConfig BulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("bulk_config"); + } + init { this._rawData.Set("bulk_config", value); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 BulkConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.BulkConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("bulk"))) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public Bulk() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Bulk(Bulk bulk) + : base(bulk) { } +#pragma warning restore CS8618 + + public Bulk(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Bulk(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Bulk FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkFromRaw : IFromRawJson +{ + /// + public Bulk FromRawUnchecked(IReadOnlyDictionary rawData) => + Bulk.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(BulkCadenceConverter))] +public enum BulkCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class BulkCadenceConverter : JsonConverter +{ + public override BulkCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => BulkCadence.Annual, + "semi_annual" => BulkCadence.SemiAnnual, + "monthly" => BulkCadence.Monthly, + "quarterly" => BulkCadence.Quarterly, + "one_time" => BulkCadence.OneTime, + "custom" => BulkCadence.Custom, + _ => (BulkCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkCadence.Annual => "annual", + BulkCadence.SemiAnnual => "semi_annual", + BulkCadence.Monthly => "monthly", + BulkCadence.Quarterly => "quarterly", + BulkCadence.OneTime => "one_time", + BulkCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public BulkLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkLicenseAllocation(BulkLicenseAllocation bulkLicenseAllocation) + : base(bulkLicenseAllocation) { } +#pragma warning restore CS8618 + + public BulkLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkLicenseAllocationFromRaw : IFromRawJson +{ + /// + public BulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(BulkConversionRateConfigConverter))] +public record class BulkConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public BulkConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkConversionRateConfig(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 BulkConversionRateConfig" + ); + } + } + + /// + /// 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 BulkConversionRateConfig" + ), + }; + } + + public static implicit operator BulkConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator BulkConversionRateConfig( + 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 BulkConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(BulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class BulkConversionRateConfigConverter : JsonConverter +{ + public override BulkConversionRateConfig? 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 BulkConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + BulkConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFilters : JsonModel +{ + /// + /// Configuration for bulk_with_filters pricing + /// + public required BulkWithFiltersConfig 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>( + "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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 BulkWithFiltersConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public BulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFilters(BulkWithFilters bulkWithFilters) + : base(bulkWithFilters) { } +#pragma warning restore CS8618 + + public BulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithFiltersFromRaw : IFromRawJson +{ + /// + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("filters"); + } + init + { + this._rawData.Set>( + "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>("tiers"); + } + init + { + this._rawData.Set>( + "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 BulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) + : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public BulkWithFiltersConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithFiltersConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithFiltersConfigFromRaw : IFromRawJson +{ + /// + public BulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Filter : 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 Filter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) + : base(filter) { } +#pragma warning restore CS8618 + + public Filter(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Filter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FilterFromRaw : IFromRawJson +{ + /// + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Tier : 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 Tier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Tier(Tier tier) + : base(tier) { } +#pragma warning restore CS8618 + + public Tier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Tier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public Tier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class TierFromRaw : IFromRawJson +{ + /// + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(BulkWithFiltersCadenceConverter))] +public enum BulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class BulkWithFiltersCadenceConverter : JsonConverter +{ + public override BulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => BulkWithFiltersCadence.Annual, + "semi_annual" => BulkWithFiltersCadence.SemiAnnual, + "monthly" => BulkWithFiltersCadence.Monthly, + "quarterly" => BulkWithFiltersCadence.Quarterly, + "one_time" => BulkWithFiltersCadence.OneTime, + "custom" => BulkWithFiltersCadence.Custom, + _ => (BulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithFiltersCadence.Annual => "annual", + BulkWithFiltersCadence.SemiAnnual => "semi_annual", + BulkWithFiltersCadence.Monthly => "monthly", + BulkWithFiltersCadence.Quarterly => "quarterly", + BulkWithFiltersCadence.OneTime => "one_time", + BulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + BulkWithFiltersLicenseAllocation, + BulkWithFiltersLicenseAllocationFromRaw + >) +)] +public sealed record class BulkWithFiltersLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public BulkWithFiltersLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersLicenseAllocation( + BulkWithFiltersLicenseAllocation bulkWithFiltersLicenseAllocation + ) + : base(bulkWithFiltersLicenseAllocation) { } +#pragma warning restore CS8618 + + public BulkWithFiltersLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithFiltersLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithFiltersLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithFiltersLicenseAllocationFromRaw : IFromRawJson +{ + /// + public BulkWithFiltersLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithFiltersLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(BulkWithFiltersConversionRateConfigConverter))] +public record class BulkWithFiltersConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public BulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkWithFiltersConversionRateConfig(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 BulkWithFiltersConversionRateConfig" + ); + } + } + + /// + /// 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 BulkWithFiltersConversionRateConfig" + ), + }; + } + + public static implicit operator BulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator BulkWithFiltersConversionRateConfig( + 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 BulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(BulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class BulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override BulkWithFiltersConversionRateConfig? 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 BulkWithFiltersConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Package : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 package pricing + /// + public required PackageConfig PackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_config"); + } + init { this._rawData.Set("package_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 PackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("package"))) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.PackageConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public Package() + { + this.ModelType = JsonSerializer.SerializeToElement("package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Package(Package package) + : base(package) { } +#pragma warning restore CS8618 + + public Package(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Package(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Package FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageFromRaw : IFromRawJson +{ + /// + public Package FromRawUnchecked(IReadOnlyDictionary rawData) => + Package.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PackageCadenceConverter))] +public enum PackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PackageCadenceConverter : JsonConverter +{ + public override PackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PackageCadence.Annual, + "semi_annual" => PackageCadence.SemiAnnual, + "monthly" => PackageCadence.Monthly, + "quarterly" => PackageCadence.Quarterly, + "one_time" => PackageCadence.OneTime, + "custom" => PackageCadence.Custom, + _ => (PackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PackageCadence.Annual => "annual", + PackageCadence.SemiAnnual => "semi_annual", + PackageCadence.Monthly => "monthly", + PackageCadence.Quarterly => "quarterly", + PackageCadence.OneTime => "one_time", + PackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public PackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageLicenseAllocation(PackageLicenseAllocation packageLicenseAllocation) + : base(packageLicenseAllocation) { } +#pragma warning restore CS8618 + + public PackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageLicenseAllocationFromRaw : IFromRawJson +{ + /// + public PackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PackageConversionRateConfigConverter))] +public record class PackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PackageConversionRateConfig(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 PackageConversionRateConfig" + ); + } + } + + /// + /// 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 PackageConversionRateConfig" + ), + }; + } + + public static implicit operator PackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PackageConversionRateConfig( + 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 PackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PackageConversionRateConfigConverter : JsonConverter +{ + public override PackageConversionRateConfig? 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 PackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Matrix : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for matrix pricing + /// + public required MatrixConfig MatrixConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("matrix_config"); + } + init { this._rawData.Set("matrix_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 MatrixConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixConfig.Validate(); + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("matrix"))) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public Matrix() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Matrix(Matrix matrix) + : base(matrix) { } +#pragma warning restore CS8618 + + public Matrix(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Matrix(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Matrix FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixFromRaw : IFromRawJson +{ + /// + public Matrix FromRawUnchecked(IReadOnlyDictionary rawData) => + Matrix.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixCadenceConverter))] +public enum MatrixCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixCadenceConverter : JsonConverter +{ + public override MatrixCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixCadence.Annual, + "semi_annual" => MatrixCadence.SemiAnnual, + "monthly" => MatrixCadence.Monthly, + "quarterly" => MatrixCadence.Quarterly, + "one_time" => MatrixCadence.OneTime, + "custom" => MatrixCadence.Custom, + _ => (MatrixCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixCadence.Annual => "annual", + MatrixCadence.SemiAnnual => "semi_annual", + MatrixCadence.Monthly => "monthly", + MatrixCadence.Quarterly => "quarterly", + MatrixCadence.OneTime => "one_time", + MatrixCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MatrixLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixLicenseAllocation(MatrixLicenseAllocation matrixLicenseAllocation) + : base(matrixLicenseAllocation) { } +#pragma warning restore CS8618 + + public MatrixLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixLicenseAllocationFromRaw : IFromRawJson +{ + /// + public MatrixLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixConversionRateConfigConverter))] +public record class MatrixConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MatrixConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixConversionRateConfig(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 MatrixConversionRateConfig" + ); + } + } + + /// + /// 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 MatrixConversionRateConfig" + ), + }; + } + + public static implicit operator MatrixConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MatrixConversionRateConfig( + 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 MatrixConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MatrixConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MatrixConversionRateConfigConverter : JsonConverter +{ + public override MatrixConversionRateConfig? 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 MatrixConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MatrixConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdTotalAmount : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 threshold_total_amount pricing + /// + public required ThresholdTotalAmountConfig ThresholdTotalAmountConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "threshold_total_amount_config" + ); + } + init { this._rawData.Set("threshold_total_amount_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 ThresholdTotalAmountConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("threshold_total_amount") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ThresholdTotalAmountConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ThresholdTotalAmount() + { + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmount(ThresholdTotalAmount thresholdTotalAmount) + : base(thresholdTotalAmount) { } +#pragma warning restore CS8618 + + public ThresholdTotalAmount(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdTotalAmount(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThresholdTotalAmountFromRaw : IFromRawJson +{ + /// + public ThresholdTotalAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmount.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ThresholdTotalAmountCadenceConverter))] +public enum ThresholdTotalAmountCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ThresholdTotalAmountCadenceConverter : JsonConverter +{ + public override ThresholdTotalAmountCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ThresholdTotalAmountCadence.Annual, + "semi_annual" => ThresholdTotalAmountCadence.SemiAnnual, + "monthly" => ThresholdTotalAmountCadence.Monthly, + "quarterly" => ThresholdTotalAmountCadence.Quarterly, + "one_time" => ThresholdTotalAmountCadence.OneTime, + "custom" => ThresholdTotalAmountCadence.Custom, + _ => (ThresholdTotalAmountCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ThresholdTotalAmountCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ThresholdTotalAmountCadence.Annual => "annual", + ThresholdTotalAmountCadence.SemiAnnual => "semi_annual", + ThresholdTotalAmountCadence.Monthly => "monthly", + ThresholdTotalAmountCadence.Quarterly => "quarterly", + ThresholdTotalAmountCadence.OneTime => "one_time", + ThresholdTotalAmountCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ThresholdTotalAmountLicenseAllocation, + ThresholdTotalAmountLicenseAllocationFromRaw + >) +)] +public sealed record class ThresholdTotalAmountLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ThresholdTotalAmountLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmountLicenseAllocation( + ThresholdTotalAmountLicenseAllocation thresholdTotalAmountLicenseAllocation + ) + : base(thresholdTotalAmountLicenseAllocation) { } +#pragma warning restore CS8618 + + public ThresholdTotalAmountLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdTotalAmountLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdTotalAmountLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThresholdTotalAmountLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ThresholdTotalAmountLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmountLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for threshold_total_amount pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class ThresholdTotalAmountConfig : JsonModel +{ + /// + /// When the quantity consumed passes a provided threshold, the configured total + /// will be charged + /// + public required IReadOnlyList ConsumptionTable + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "consumption_table" + ); + } + init + { + this._rawData.Set>( + "consumption_table", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init { this._rawData.Set("prorate", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.ConsumptionTable) + { + item.Validate(); + } + _ = this.Prorate; + } + + public ThresholdTotalAmountConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmountConfig(ThresholdTotalAmountConfig thresholdTotalAmountConfig) + : base(thresholdTotalAmountConfig) { } +#pragma warning restore CS8618 + + public ThresholdTotalAmountConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdTotalAmountConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ThresholdTotalAmountConfig(IReadOnlyList consumptionTable) + : this() + { + this.ConsumptionTable = consumptionTable; + } +} + +class ThresholdTotalAmountConfigFromRaw : IFromRawJson +{ + /// + public ThresholdTotalAmountConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdTotalAmountConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single threshold +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ConsumptionTable : JsonModel +{ + public required string Threshold + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold"); + } + init { this._rawData.Set("threshold", value); } + } + + /// + /// Total amount for this threshold + /// + public required string TotalAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total_amount"); + } + init { this._rawData.Set("total_amount", value); } + } + + /// + public override void Validate() + { + _ = this.Threshold; + _ = this.TotalAmount; + } + + public ConsumptionTable() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ConsumptionTable(ConsumptionTable consumptionTable) + : base(consumptionTable) { } +#pragma warning restore CS8618 + + public ConsumptionTable(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ConsumptionTable(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ConsumptionTable FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ConsumptionTableFromRaw : IFromRawJson +{ + /// + public ConsumptionTable FromRawUnchecked(IReadOnlyDictionary rawData) => + ConsumptionTable.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ThresholdTotalAmountConversionRateConfigConverter))] +public record class ThresholdTotalAmountConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ThresholdTotalAmountConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ThresholdTotalAmountConversionRateConfig(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 ThresholdTotalAmountConversionRateConfig" + ); + } + } + + /// + /// 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 ThresholdTotalAmountConversionRateConfig" + ), + }; + } + + public static implicit operator ThresholdTotalAmountConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ThresholdTotalAmountConversionRateConfig( + 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 ThresholdTotalAmountConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ThresholdTotalAmountConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ThresholdTotalAmountConversionRateConfigConverter + : JsonConverter +{ + public override ThresholdTotalAmountConversionRateConfig? 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 ThresholdTotalAmountConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ThresholdTotalAmountConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackage : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_package pricing + /// + public required TieredPackageConfig TieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tiered_package_config"); + } + init { this._rawData.Set("tiered_package_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 TieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackage(TieredPackage tieredPackage) + : base(tieredPackage) { } +#pragma warning restore CS8618 + + public TieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackage FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageFromRaw : IFromRawJson +{ + /// + public TieredPackage FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredPackageCadenceConverter))] +public enum TieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredPackageCadenceConverter : JsonConverter +{ + public override TieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredPackageCadence.Annual, + "semi_annual" => TieredPackageCadence.SemiAnnual, + "monthly" => TieredPackageCadence.Monthly, + "quarterly" => TieredPackageCadence.Quarterly, + "one_time" => TieredPackageCadence.OneTime, + "custom" => TieredPackageCadence.Custom, + _ => (TieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredPackageCadence.Annual => "annual", + TieredPackageCadence.SemiAnnual => "semi_annual", + TieredPackageCadence.Monthly => "monthly", + TieredPackageCadence.Quarterly => "quarterly", + TieredPackageCadence.OneTime => "one_time", + TieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageLicenseAllocation, + TieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class TieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageLicenseAllocation( + TieredPackageLicenseAllocation tieredPackageLicenseAllocation + ) + : base(tieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageLicenseAllocationFromRaw : IFromRawJson +{ + /// + public TieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_package pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackageConfig : JsonModel +{ + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. The tier bounds are defined + /// based on the total quantity rather than the number of packages, so they must + /// be multiples of the package size. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageConfig(TieredPackageConfig tieredPackageConfig) + : base(tieredPackageConfig) { } +#pragma warning restore CS8618 + + public TieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageConfigFromRaw : IFromRawJson +{ + /// + public TieredPackageConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier with business logic +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackageConfigTier : JsonModel +{ + /// + /// Price per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public TieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageConfigTier(TieredPackageConfigTier tieredPackageConfigTier) + : base(tieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public TieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public TieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredPackageConversionRateConfigConverter))] +public record class TieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageConversionRateConfig(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 TieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 TieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator TieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredPackageConversionRateConfig( + 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 TieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override TieredPackageConversionRateConfig? 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 TieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithMinimum : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_with_minimum pricing + /// + public required TieredWithMinimumConfig TieredWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_with_minimum_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 TieredWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimum(TieredWithMinimum tieredWithMinimum) + : base(tieredWithMinimum) { } +#pragma warning restore CS8618 + + public TieredWithMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumFromRaw : IFromRawJson +{ + /// + public TieredWithMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithMinimumCadenceConverter))] +public enum TieredWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithMinimumCadenceConverter : JsonConverter +{ + public override TieredWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredWithMinimumCadence.Annual, + "semi_annual" => TieredWithMinimumCadence.SemiAnnual, + "monthly" => TieredWithMinimumCadence.Monthly, + "quarterly" => TieredWithMinimumCadence.Quarterly, + "one_time" => TieredWithMinimumCadence.OneTime, + "custom" => TieredWithMinimumCadence.Custom, + _ => (TieredWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredWithMinimumCadence.Annual => "annual", + TieredWithMinimumCadence.SemiAnnual => "semi_annual", + TieredWithMinimumCadence.Monthly => "monthly", + TieredWithMinimumCadence.Quarterly => "quarterly", + TieredWithMinimumCadence.OneTime => "one_time", + TieredWithMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredWithMinimumLicenseAllocation, + TieredWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class TieredWithMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumLicenseAllocation( + TieredWithMinimumLicenseAllocation tieredWithMinimumLicenseAllocation + ) + : base(tieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithMinimumLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumLicenseAllocationFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_with_minimum pricing +/// +[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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// If true, tiers with an accrued amount of 0 will not be included in the rating. + /// + public bool? HideZeroAmountTiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hide_zero_amount_tiers"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("hide_zero_amount_tiers", value); + } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prorate", value); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.HideZeroAmountTiers; + _ = this.Prorate; + } + + public TieredWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) + : base(tieredWithMinimumConfig) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithMinimumConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithMinimumConfigFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithMinimumConfigTier : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.MinimumAmount; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public TieredWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfigTier(TieredWithMinimumConfigTier tieredWithMinimumConfigTier) + : base(tieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithMinimumConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithMinimumConversionRateConfigConverter))] +public record class TieredWithMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithMinimumConversionRateConfig(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 TieredWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 TieredWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator TieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredWithMinimumConversionRateConfig( + 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 TieredWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithMinimumConversionRateConfig? 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 TieredWithMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTiered : 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); } + } + + /// + /// Configuration for grouped_tiered pricing + /// + public required GroupedTieredConfig GroupedTieredConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouped_tiered_config"); + } + init { this._rawData.Set("grouped_tiered_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedTieredConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedTiered() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTiered(GroupedTiered groupedTiered) + : base(groupedTiered) { } +#pragma warning restore CS8618 + + public GroupedTiered(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTiered(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTiered FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredFromRaw : IFromRawJson +{ + /// + public GroupedTiered FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTiered.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedTieredCadenceConverter))] +public enum GroupedTieredCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedTieredCadenceConverter : JsonConverter +{ + public override GroupedTieredCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedTieredCadence.Annual, + "semi_annual" => GroupedTieredCadence.SemiAnnual, + "monthly" => GroupedTieredCadence.Monthly, + "quarterly" => GroupedTieredCadence.Quarterly, + "one_time" => GroupedTieredCadence.OneTime, + "custom" => GroupedTieredCadence.Custom, + _ => (GroupedTieredCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedTieredCadence.Annual => "annual", + GroupedTieredCadence.SemiAnnual => "semi_annual", + GroupedTieredCadence.Monthly => "monthly", + GroupedTieredCadence.Quarterly => "quarterly", + GroupedTieredCadence.OneTime => "one_time", + GroupedTieredCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredConfig : JsonModel +{ + /// + /// The billable metric property used to group before tiering + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Apply tiered pricing to each segment generated after grouping with the provided key + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public GroupedTieredConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) + : base(groupedTieredConfig) { } +#pragma warning restore CS8618 + + public GroupedTieredConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredConfigFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTieredConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredConfigTier : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public GroupedTieredConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) + : base(groupedTieredConfigTier) { } +#pragma warning restore CS8618 + + public GroupedTieredConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredConfigTierFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredLicenseAllocation, + GroupedTieredLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedTieredLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedTieredLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredLicenseAllocation( + GroupedTieredLicenseAllocation groupedTieredLicenseAllocation + ) + : base(groupedTieredLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedTieredLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredLicenseAllocationFromRaw : IFromRawJson +{ + /// + public GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedTieredConversionRateConfigConverter))] +public record class GroupedTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredConversionRateConfig(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 GroupedTieredConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedTieredConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedTieredConversionRateConfig( + 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 GroupedTieredConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedTieredConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedTieredConversionRateConfigConverter + : JsonConverter +{ + public override GroupedTieredConversionRateConfig? 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 GroupedTieredConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredPackageWithMinimum : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_package_with_minimum pricing + /// + public required TieredPackageWithMinimumConfig TieredPackageWithMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_package_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_package_with_minimum_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 TieredPackageWithMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_package_with_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredPackageWithMinimumConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredPackageWithMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimum(TieredPackageWithMinimum tieredPackageWithMinimum) + : base(tieredPackageWithMinimum) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredPackageWithMinimumCadenceConverter))] +public enum TieredPackageWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredPackageWithMinimumCadenceConverter + : JsonConverter +{ + public override TieredPackageWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredPackageWithMinimumCadence.Annual, + "semi_annual" => TieredPackageWithMinimumCadence.SemiAnnual, + "monthly" => TieredPackageWithMinimumCadence.Monthly, + "quarterly" => TieredPackageWithMinimumCadence.Quarterly, + "one_time" => TieredPackageWithMinimumCadence.OneTime, + "custom" => TieredPackageWithMinimumCadence.Custom, + _ => (TieredPackageWithMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageWithMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredPackageWithMinimumCadence.Annual => "annual", + TieredPackageWithMinimumCadence.SemiAnnual => "semi_annual", + TieredPackageWithMinimumCadence.Monthly => "monthly", + TieredPackageWithMinimumCadence.Quarterly => "quarterly", + TieredPackageWithMinimumCadence.OneTime => "one_time", + TieredPackageWithMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumLicenseAllocation, + TieredPackageWithMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredPackageWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumLicenseAllocation( + TieredPackageWithMinimumLicenseAllocation tieredPackageWithMinimumLicenseAllocation + ) + : base(tieredPackageWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_package_with_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumConfig, + TieredPackageWithMinimumConfigFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumConfig : JsonModel +{ + public required double PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredPackageWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumConfig( + TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig + ) + : base(tieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumConfigFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredPackageWithMinimumConfigTier, + TieredPackageWithMinimumConfigTierFromRaw + >) +)] +public sealed record class TieredPackageWithMinimumConfigTier : JsonModel +{ + public required string MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } + + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.MinimumAmount; + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public TieredPackageWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumConfigTier( + TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier + ) + : base(tieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackageWithMinimumConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredPackageWithMinimumConfigTierFromRaw : IFromRawJson +{ + /// + public TieredPackageWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredPackageWithMinimumConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredPackageWithMinimumConversionRateConfigConverter))] +public record class TieredPackageWithMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredPackageWithMinimumConversionRateConfig(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 TieredPackageWithMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 TieredPackageWithMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator TieredPackageWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredPackageWithMinimumConversionRateConfig( + 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 TieredPackageWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredPackageWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredPackageWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override TieredPackageWithMinimumConversionRateConfig? 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 TieredPackageWithMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredPackageWithMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PackageWithAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 package_with_allocation pricing + /// + public required PackageWithAllocationConfig PackageWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "package_with_allocation_config" + ); + } + init { this._rawData.Set("package_with_allocation_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 PackageWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("package_with_allocation") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.PackageWithAllocationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public PackageWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocation(PackageWithAllocation packageWithAllocation) + : base(packageWithAllocation) { } +#pragma warning restore CS8618 + + public PackageWithAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("package_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationFromRaw : IFromRawJson +{ + /// + public PackageWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PackageWithAllocationCadenceConverter))] +public enum PackageWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PackageWithAllocationCadenceConverter : JsonConverter +{ + public override PackageWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PackageWithAllocationCadence.Annual, + "semi_annual" => PackageWithAllocationCadence.SemiAnnual, + "monthly" => PackageWithAllocationCadence.Monthly, + "quarterly" => PackageWithAllocationCadence.Quarterly, + "one_time" => PackageWithAllocationCadence.OneTime, + "custom" => PackageWithAllocationCadence.Custom, + _ => (PackageWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PackageWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PackageWithAllocationCadence.Annual => "annual", + PackageWithAllocationCadence.SemiAnnual => "semi_annual", + PackageWithAllocationCadence.Monthly => "monthly", + PackageWithAllocationCadence.Quarterly => "quarterly", + PackageWithAllocationCadence.OneTime => "one_time", + PackageWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PackageWithAllocationLicenseAllocation, + PackageWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class PackageWithAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public PackageWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocationLicenseAllocation( + PackageWithAllocationLicenseAllocation packageWithAllocationLicenseAllocation + ) + : base(packageWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public PackageWithAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public PackageWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for package_with_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PackageWithAllocationConfig : JsonModel +{ + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + public required string PackageAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_amount"); + } + init { this._rawData.Set("package_amount", value); } + } + + public required string PackageSize + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.PackageAmount; + _ = this.PackageSize; + } + + public PackageWithAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocationConfig(PackageWithAllocationConfig packageWithAllocationConfig) + : base(packageWithAllocationConfig) { } +#pragma warning restore CS8618 + + public PackageWithAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PackageWithAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PackageWithAllocationConfigFromRaw : IFromRawJson +{ + /// + public PackageWithAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PackageWithAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PackageWithAllocationConversionRateConfigConverter))] +public record class PackageWithAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PackageWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PackageWithAllocationConversionRateConfig(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 PackageWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 PackageWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator PackageWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PackageWithAllocationConversionRateConfig( + 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 PackageWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PackageWithAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PackageWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override PackageWithAllocationConversionRateConfig? 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 PackageWithAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PackageWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithPercent : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 unit_with_percent pricing + /// + public required UnitWithPercentConfig UnitWithPercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_with_percent_config"); + } + init { this._rawData.Set("unit_with_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 UnitWithPercentConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_percent") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithPercentConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public UnitWithPercent() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercent(UnitWithPercent unitWithPercent) + : base(unitWithPercent) { } +#pragma warning restore CS8618 + + public UnitWithPercent(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercent(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercent FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentFromRaw : IFromRawJson +{ + /// + public UnitWithPercent FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitWithPercent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(UnitWithPercentCadenceConverter))] +public enum UnitWithPercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class UnitWithPercentCadenceConverter : JsonConverter +{ + public override UnitWithPercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => UnitWithPercentCadence.Annual, + "semi_annual" => UnitWithPercentCadence.SemiAnnual, + "monthly" => UnitWithPercentCadence.Monthly, + "quarterly" => UnitWithPercentCadence.Quarterly, + "one_time" => UnitWithPercentCadence.OneTime, + "custom" => UnitWithPercentCadence.Custom, + _ => (UnitWithPercentCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithPercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UnitWithPercentCadence.Annual => "annual", + UnitWithPercentCadence.SemiAnnual => "semi_annual", + UnitWithPercentCadence.Monthly => "monthly", + UnitWithPercentCadence.Quarterly => "quarterly", + UnitWithPercentCadence.OneTime => "one_time", + UnitWithPercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnitWithPercentLicenseAllocation, + UnitWithPercentLicenseAllocationFromRaw + >) +)] +public sealed record class UnitWithPercentLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public UnitWithPercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercentLicenseAllocation( + UnitWithPercentLicenseAllocation unitWithPercentLicenseAllocation + ) + : base(unitWithPercentLicenseAllocation) { } +#pragma warning restore CS8618 + + public UnitWithPercentLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercentLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentLicenseAllocationFromRaw : IFromRawJson +{ + /// + public UnitWithPercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithPercentLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for unit_with_percent pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithPercentConfig : JsonModel +{ + /// + /// What percent, out of 100, of the calculated total to charge + /// + public required string Percent + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent"); + } + init { this._rawData.Set("percent", value); } + } + + /// + /// Rate per unit of usage + /// + 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.Percent; + _ = this.UnitAmount; + } + + public UnitWithPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercentConfig(UnitWithPercentConfig unitWithPercentConfig) + : base(unitWithPercentConfig) { } +#pragma warning restore CS8618 + + public UnitWithPercentConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithPercentConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithPercentConfigFromRaw : IFromRawJson +{ + /// + public UnitWithPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithPercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UnitWithPercentConversionRateConfigConverter))] +public record class UnitWithPercentConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithPercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithPercentConversionRateConfig(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 UnitWithPercentConversionRateConfig" + ); + } + } + + /// + /// 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 UnitWithPercentConversionRateConfig" + ), + }; + } + + public static implicit operator UnitWithPercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator UnitWithPercentConversionRateConfig( + 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 UnitWithPercentConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(UnitWithPercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class UnitWithPercentConversionRateConfigConverter + : JsonConverter +{ + public override UnitWithPercentConversionRateConfig? 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 UnitWithPercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithPercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixWithAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for matrix_with_allocation pricing + /// + public required MatrixWithAllocationConfig MatrixWithAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_allocation_config" + ); + } + init { this._rawData.Set("matrix_with_allocation_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 MatrixWithAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithAllocationConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MatrixWithAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithAllocation(MatrixWithAllocation matrixWithAllocation) + : base(matrixWithAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithAllocationFromRaw : IFromRawJson +{ + /// + public MatrixWithAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixWithAllocationCadenceConverter))] +public enum MatrixWithAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixWithAllocationCadenceConverter : JsonConverter +{ + public override MatrixWithAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixWithAllocationCadence.Annual, + "semi_annual" => MatrixWithAllocationCadence.SemiAnnual, + "monthly" => MatrixWithAllocationCadence.Monthly, + "quarterly" => MatrixWithAllocationCadence.Quarterly, + "one_time" => MatrixWithAllocationCadence.OneTime, + "custom" => MatrixWithAllocationCadence.Custom, + _ => (MatrixWithAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixWithAllocationCadence.Annual => "annual", + MatrixWithAllocationCadence.SemiAnnual => "semi_annual", + MatrixWithAllocationCadence.Monthly => "monthly", + MatrixWithAllocationCadence.Quarterly => "quarterly", + MatrixWithAllocationCadence.OneTime => "one_time", + MatrixWithAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithAllocationLicenseAllocation, + MatrixWithAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class MatrixWithAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MatrixWithAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithAllocationLicenseAllocation( + MatrixWithAllocationLicenseAllocation matrixWithAllocationLicenseAllocation + ) + : base(matrixWithAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MatrixWithAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithAllocationConversionRateConfigConverter))] +public record class MatrixWithAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithAllocationConversionRateConfig(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 MatrixWithAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 MatrixWithAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator MatrixWithAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MatrixWithAllocationConversionRateConfig( + 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 MatrixWithAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MatrixWithAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MatrixWithAllocationConversionRateConfigConverter + : JsonConverter +{ + public override MatrixWithAllocationConversionRateConfig? 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 MatrixWithAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithProration : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 tiered_with_proration pricing + /// + public required TieredWithProrationConfig 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. + /// + 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 TieredWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + 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(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 + + public TieredWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationFromRaw : IFromRawJson +{ + /// + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithProrationCadenceConverter : JsonConverter +{ + public override TieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + TieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + TieredWithProrationLicenseAllocation, + TieredWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class TieredWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public TieredWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationLicenseAllocation( + TieredWithProrationLicenseAllocation tieredWithProrationLicenseAllocation + ) + : base(tieredWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public TieredWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfig : 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>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) + : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithProrationConfigFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfigTier : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + 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 TieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier + ) + : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig(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 TieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 TieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredWithProrationConversionRateConfig( + 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 TieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithProrationConversionRateConfig? 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 TieredWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithProration : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 unit_with_proration pricing + /// + public required UnitWithProrationConfig UnitWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "unit_with_proration_config" + ); + } + init { this._rawData.Set("unit_with_proration_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 UnitWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("unit_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.UnitWithProrationConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public UnitWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProration(UnitWithProration unitWithProration) + : base(unitWithProration) { } +#pragma warning restore CS8618 + + public UnitWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithProrationFromRaw : IFromRawJson +{ + /// + public UnitWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(UnitWithProrationCadenceConverter))] +public enum UnitWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class UnitWithProrationCadenceConverter : JsonConverter +{ + public override UnitWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => UnitWithProrationCadence.Annual, + "semi_annual" => UnitWithProrationCadence.SemiAnnual, + "monthly" => UnitWithProrationCadence.Monthly, + "quarterly" => UnitWithProrationCadence.Quarterly, + "one_time" => UnitWithProrationCadence.OneTime, + "custom" => UnitWithProrationCadence.Custom, + _ => (UnitWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UnitWithProrationCadence.Annual => "annual", + UnitWithProrationCadence.SemiAnnual => "semi_annual", + UnitWithProrationCadence.Monthly => "monthly", + UnitWithProrationCadence.Quarterly => "quarterly", + UnitWithProrationCadence.OneTime => "one_time", + UnitWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + UnitWithProrationLicenseAllocation, + UnitWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class UnitWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public UnitWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationLicenseAllocation( + UnitWithProrationLicenseAllocation unitWithProrationLicenseAllocation + ) + : base(unitWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public UnitWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithProrationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public UnitWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for unit_with_proration pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithProrationConfig : JsonModel +{ + /// + /// Rate per unit of usage + /// + 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.UnitAmount; + } + + public UnitWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationConfig(UnitWithProrationConfig unitWithProrationConfig) + : base(unitWithProrationConfig) { } +#pragma warning restore CS8618 + + public UnitWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnitWithProrationConfig(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class UnitWithProrationConfigFromRaw : IFromRawJson +{ + /// + public UnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithProrationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(UnitWithProrationConversionRateConfigConverter))] +public record class UnitWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public UnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public UnitWithProrationConversionRateConfig(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 UnitWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 UnitWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator UnitWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator UnitWithProrationConversionRateConfig( + 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 UnitWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(UnitWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class UnitWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override UnitWithProrationConversionRateConfig? 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 UnitWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedAllocation : 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); } + } + + /// + /// Configuration for grouped_allocation pricing + /// + public required GroupedAllocationConfig GroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_allocation_config" + ); + } + init { this._rawData.Set("grouped_allocation_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocation(GroupedAllocation groupedAllocation) + : base(groupedAllocation) { } +#pragma warning restore CS8618 + + public GroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationFromRaw : IFromRawJson +{ + /// + public GroupedAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedAllocationCadenceConverter))] +public enum GroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedAllocationCadenceConverter : JsonConverter +{ + public override GroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedAllocationCadence.Annual, + "semi_annual" => GroupedAllocationCadence.SemiAnnual, + "monthly" => GroupedAllocationCadence.Monthly, + "quarterly" => GroupedAllocationCadence.Quarterly, + "one_time" => GroupedAllocationCadence.OneTime, + "custom" => GroupedAllocationCadence.Custom, + _ => (GroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedAllocationCadence.Annual => "annual", + GroupedAllocationCadence.SemiAnnual => "semi_annual", + GroupedAllocationCadence.Monthly => "monthly", + GroupedAllocationCadence.Quarterly => "quarterly", + GroupedAllocationCadence.OneTime => "one_time", + GroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_allocation pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedAllocationConfig : JsonModel +{ + /// + /// Usage allocation per group + /// + public required string Allocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allocation"); + } + init { this._rawData.Set("allocation", value); } + } + + /// + /// How to determine the groups that should each be allocated some quantity + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Unit rate for post-allocation + /// + public required string OverageUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("overage_unit_rate"); + } + init { this._rawData.Set("overage_unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.Allocation; + _ = this.GroupingKey; + _ = this.OverageUnitRate; + } + + public GroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationConfig(GroupedAllocationConfig groupedAllocationConfig) + : base(groupedAllocationConfig) { } +#pragma warning restore CS8618 + + public GroupedAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationConfigFromRaw : IFromRawJson +{ + /// + public GroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedAllocationLicenseAllocation, + GroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationLicenseAllocation( + GroupedAllocationLicenseAllocation groupedAllocationLicenseAllocation + ) + : base(groupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedAllocationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public GroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedAllocationConversionRateConfigConverter))] +public record class GroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedAllocationConversionRateConfig(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 GroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedAllocationConversionRateConfig( + 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 GroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override GroupedAllocationConversionRateConfig? 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 GroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithProration : JsonModel +{ + /// + /// Configuration for bulk_with_proration pricing + /// + public required BulkWithProrationConfig BulkWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_proration_config" + ); + } + init { this._rawData.Set("bulk_with_proration_config", value); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 BulkWithProrationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.BulkWithProrationConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("bulk_with_proration") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public BulkWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProration(BulkWithProration bulkWithProration) + : base(bulkWithProration) { } +#pragma warning restore CS8618 + + public BulkWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationFromRaw : IFromRawJson +{ + /// + public BulkWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithProration.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_proration pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithProrationConfig : JsonModel +{ + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public BulkWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationConfig(BulkWithProrationConfig bulkWithProrationConfig) + : base(bulkWithProrationConfig) { } +#pragma warning restore CS8618 + + public BulkWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BulkWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class BulkWithProrationConfigFromRaw : IFromRawJson +{ + /// + public BulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier with proration +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class BulkWithProrationConfigTier : JsonModel +{ + /// + /// Cost 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 BulkWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationConfigTier(BulkWithProrationConfigTier bulkWithProrationConfigTier) + : base(bulkWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public BulkWithProrationConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BulkWithProrationConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class BulkWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public BulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(BulkWithProrationCadenceConverter))] +public enum BulkWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class BulkWithProrationCadenceConverter : JsonConverter +{ + public override BulkWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => BulkWithProrationCadence.Annual, + "semi_annual" => BulkWithProrationCadence.SemiAnnual, + "monthly" => BulkWithProrationCadence.Monthly, + "quarterly" => BulkWithProrationCadence.Quarterly, + "one_time" => BulkWithProrationCadence.OneTime, + "custom" => BulkWithProrationCadence.Custom, + _ => (BulkWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithProrationCadence.Annual => "annual", + BulkWithProrationCadence.SemiAnnual => "semi_annual", + BulkWithProrationCadence.Monthly => "monthly", + BulkWithProrationCadence.Quarterly => "quarterly", + BulkWithProrationCadence.OneTime => "one_time", + BulkWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + BulkWithProrationLicenseAllocation, + BulkWithProrationLicenseAllocationFromRaw + >) +)] +public sealed record class BulkWithProrationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public BulkWithProrationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationLicenseAllocation( + BulkWithProrationLicenseAllocation bulkWithProrationLicenseAllocation + ) + : base(bulkWithProrationLicenseAllocation) { } +#pragma warning restore CS8618 + + public BulkWithProrationLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationLicenseAllocationFromRaw : IFromRawJson +{ + /// + public BulkWithProrationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(BulkWithProrationConversionRateConfigConverter))] +public record class BulkWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public BulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public BulkWithProrationConversionRateConfig(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 BulkWithProrationConversionRateConfig" + ); + } + } + + /// + /// 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 BulkWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator BulkWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator BulkWithProrationConversionRateConfig( + 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 BulkWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(BulkWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class BulkWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override BulkWithProrationConversionRateConfig? 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 BulkWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithProratedMinimum : 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); } + } + + /// + /// Configuration for grouped_with_prorated_minimum pricing + /// + public required GroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_prorated_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_prorated_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithProratedMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithProratedMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_prorated_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithProratedMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimum(GroupedWithProratedMinimum groupedWithProratedMinimum) + : base(groupedWithProratedMinimum) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumFromRaw : IFromRawJson +{ + /// + public GroupedWithProratedMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithProratedMinimumCadenceConverter))] +public enum GroupedWithProratedMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithProratedMinimumCadenceConverter + : JsonConverter +{ + public override GroupedWithProratedMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedWithProratedMinimumCadence.Annual, + "semi_annual" => GroupedWithProratedMinimumCadence.SemiAnnual, + "monthly" => GroupedWithProratedMinimumCadence.Monthly, + "quarterly" => GroupedWithProratedMinimumCadence.Quarterly, + "one_time" => GroupedWithProratedMinimumCadence.OneTime, + "custom" => GroupedWithProratedMinimumCadence.Custom, + _ => (GroupedWithProratedMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithProratedMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithProratedMinimumCadence.Annual => "annual", + GroupedWithProratedMinimumCadence.SemiAnnual => "semi_annual", + GroupedWithProratedMinimumCadence.Monthly => "monthly", + GroupedWithProratedMinimumCadence.Quarterly => "quarterly", + GroupedWithProratedMinimumCadence.OneTime => "one_time", + GroupedWithProratedMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_prorated_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumConfig, + GroupedWithProratedMinimumConfigFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumConfig : JsonModel +{ + /// + /// How to determine the groups that should each have a minimum + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group + /// + public required string Minimum + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum"); + } + init { this._rawData.Set("minimum", value); } + } + + /// + /// The amount to charge per unit + /// + public required string UnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rate"); + } + init { this._rawData.Set("unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.Minimum; + _ = this.UnitRate; + } + + public GroupedWithProratedMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumConfig( + GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig + ) + : base(groupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumConfigFromRaw : IFromRawJson +{ + /// + public GroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumLicenseAllocation, + GroupedWithProratedMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithProratedMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumLicenseAllocation( + GroupedWithProratedMinimumLicenseAllocation groupedWithProratedMinimumLicenseAllocation + ) + : base(groupedWithProratedMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithProratedMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedWithProratedMinimumConversionRateConfigConverter))] +public record class GroupedWithProratedMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithProratedMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithProratedMinimumConversionRateConfig(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 GroupedWithProratedMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedWithProratedMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedWithProratedMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedWithProratedMinimumConversionRateConfig( + 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 GroupedWithProratedMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedWithProratedMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedWithProratedMinimumConversionRateConfigConverter + : JsonConverter +{ + public override GroupedWithProratedMinimumConversionRateConfig? 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 GroupedWithProratedMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithProratedMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithMeteredMinimum : 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); } + } + + /// + /// Configuration for grouped_with_metered_minimum pricing + /// + public required GroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_metered_minimum_config" + ); + } + init { this._rawData.Set("grouped_with_metered_minimum_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithMeteredMinimumConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMeteredMinimumConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_metered_minimum") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithMeteredMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimum(GroupedWithMeteredMinimum groupedWithMeteredMinimum) + : base(groupedWithMeteredMinimum) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimum(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimum(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumFromRaw : IFromRawJson +{ + /// + public GroupedWithMeteredMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimum.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithMeteredMinimumCadenceConverter))] +public enum GroupedWithMeteredMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithMeteredMinimumCadenceConverter + : JsonConverter +{ + public override GroupedWithMeteredMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedWithMeteredMinimumCadence.Annual, + "semi_annual" => GroupedWithMeteredMinimumCadence.SemiAnnual, + "monthly" => GroupedWithMeteredMinimumCadence.Monthly, + "quarterly" => GroupedWithMeteredMinimumCadence.Quarterly, + "one_time" => GroupedWithMeteredMinimumCadence.OneTime, + "custom" => GroupedWithMeteredMinimumCadence.Custom, + _ => (GroupedWithMeteredMinimumCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithMeteredMinimumCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithMeteredMinimumCadence.Annual => "annual", + GroupedWithMeteredMinimumCadence.SemiAnnual => "semi_annual", + GroupedWithMeteredMinimumCadence.Monthly => "monthly", + GroupedWithMeteredMinimumCadence.Quarterly => "quarterly", + GroupedWithMeteredMinimumCadence.OneTime => "one_time", + GroupedWithMeteredMinimumCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_metered_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumConfig, + GroupedWithMeteredMinimumConfigFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumConfig : JsonModel +{ + /// + /// Used to partition the usage into groups. The minimum amount is applied to + /// each group. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The minimum amount to charge per group per unit + /// + public required string MinimumUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_unit_amount"); + } + init { this._rawData.Set("minimum_unit_amount", value); } + } + + /// + /// Used to determine the unit rate + /// + public required string PricingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_key"); + } + init { this._rawData.Set("pricing_key", value); } + } + + /// + /// Scale the unit rates by the scaling factor. + /// + public required IReadOnlyList ScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("scaling_factors"); + } + init + { + this._rawData.Set>( + "scaling_factors", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Used to determine the unit rate scaling factor + /// + public required string ScalingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_key"); + } + init { this._rawData.Set("scaling_key", value); } + } + + /// + /// Apply per unit pricing to each pricing value. The minimum amount is applied + /// any unmatched usage. + /// + public required IReadOnlyList UnitAmounts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("unit_amounts"); + } + init + { + this._rawData.Set>( + "unit_amounts", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.MinimumUnitAmount; + _ = this.PricingKey; + foreach (var item in this.ScalingFactors) + { + item.Validate(); + } + _ = this.ScalingKey; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public GroupedWithMeteredMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumConfig( + GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig + ) + : base(groupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumConfigFromRaw : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimumConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a scaling factor +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ScalingFactor : JsonModel +{ + public required string ScalingFactorValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public required string ScalingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_value"); + } + init { this._rawData.Set("scaling_value", value); } + } + + /// + public override void Validate() + { + _ = this.ScalingFactorValue; + _ = this.ScalingValue; + } + + public ScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalingFactor(ScalingFactor scalingFactor) + : base(scalingFactor) { } +#pragma warning restore CS8618 + + public ScalingFactor(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalingFactor(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalingFactorFromRaw : IFromRawJson +{ + /// + public ScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) => + ScalingFactor.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a unit amount +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitAmount : JsonModel +{ + public required string PricingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_value"); + } + init { this._rawData.Set("pricing_value", value); } + } + + /// + /// Per unit amount + /// + public required string UnitAmountValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.PricingValue; + _ = this.UnitAmountValue; + } + + public UnitAmount() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitAmount(UnitAmount unitAmount) + : base(unitAmount) { } +#pragma warning restore CS8618 + + public UnitAmount(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitAmount(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitAmount FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitAmountFromRaw : IFromRawJson +{ + /// + public UnitAmount FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitAmount.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumLicenseAllocation, + GroupedWithMeteredMinimumLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithMeteredMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumLicenseAllocation( + GroupedWithMeteredMinimumLicenseAllocation groupedWithMeteredMinimumLicenseAllocation + ) + : base(groupedWithMeteredMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimumLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedWithMeteredMinimumConversionRateConfigConverter))] +public record class GroupedWithMeteredMinimumConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithMeteredMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedWithMeteredMinimumConversionRateConfig(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 GroupedWithMeteredMinimumConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedWithMeteredMinimumConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( + 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 GroupedWithMeteredMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedWithMeteredMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedWithMeteredMinimumConversionRateConfigConverter + : JsonConverter +{ + public override GroupedWithMeteredMinimumConversionRateConfig? 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 GroupedWithMeteredMinimumConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithMeteredMinimumConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithMinMaxThresholds : 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); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [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); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override GroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + GroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + 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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + ) + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 + + 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(JsonModelConverter< + GroupedWithMinMaxThresholdsLicenseAllocation, + GroupedWithMinMaxThresholdsLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedWithMinMaxThresholdsLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedWithMinMaxThresholdsLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsLicenseAllocation( + GroupedWithMinMaxThresholdsLicenseAllocation groupedWithMinMaxThresholdsLicenseAllocation + ) + : base(groupedWithMinMaxThresholdsLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholdsLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMinMaxThresholdsLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMinMaxThresholdsLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedWithMinMaxThresholdsLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMinMaxThresholdsLicenseAllocation.FromRawUnchecked(rawData); +} + +[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) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +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); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixWithDisplayName : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for matrix_with_display_name pricing + /// + public required MatrixWithDisplayNameConfig MatrixWithDisplayNameConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_display_name_config" + ); + } + init { this._rawData.Set("matrix_with_display_name_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 MatrixWithDisplayNameConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MatrixWithDisplayNameConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_display_name") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MatrixWithDisplayName() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) + : base(matrixWithDisplayName) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayName(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayName(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameFromRaw : IFromRawJson +{ + /// + public MatrixWithDisplayName FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayName.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixWithDisplayNameCadenceConverter))] +public enum MatrixWithDisplayNameCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixWithDisplayNameCadenceConverter : JsonConverter +{ + public override MatrixWithDisplayNameCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixWithDisplayNameCadence.Annual, + "semi_annual" => MatrixWithDisplayNameCadence.SemiAnnual, + "monthly" => MatrixWithDisplayNameCadence.Monthly, + "quarterly" => MatrixWithDisplayNameCadence.Quarterly, + "one_time" => MatrixWithDisplayNameCadence.OneTime, + "custom" => MatrixWithDisplayNameCadence.Custom, + _ => (MatrixWithDisplayNameCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithDisplayNameCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixWithDisplayNameCadence.Annual => "annual", + MatrixWithDisplayNameCadence.SemiAnnual => "semi_annual", + MatrixWithDisplayNameCadence.Monthly => "monthly", + MatrixWithDisplayNameCadence.Quarterly => "quarterly", + MatrixWithDisplayNameCadence.OneTime => "one_time", + MatrixWithDisplayNameCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameLicenseAllocation, + MatrixWithDisplayNameLicenseAllocationFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MatrixWithDisplayNameLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameLicenseAllocation( + MatrixWithDisplayNameLicenseAllocation matrixWithDisplayNameLicenseAllocation + ) + : base(matrixWithDisplayNameLicenseAllocation) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MatrixWithDisplayNameLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for matrix_with_display_name pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class MatrixWithDisplayNameConfig : 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 + /// + public required IReadOnlyList UnitAmounts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("unit_amounts"); + } + init + { + this._rawData.Set>( + "unit_amounts", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.Dimension; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public MatrixWithDisplayNameConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameConfig(MatrixWithDisplayNameConfig matrixWithDisplayNameConfig) + : base(matrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameConfigFromRaw : IFromRawJson +{ + /// + public MatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a unit amount item +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameConfigUnitAmount, + MatrixWithDisplayNameConfigUnitAmountFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameConfigUnitAmount : JsonModel +{ + /// + /// The dimension value + /// + public required string DimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("dimension_value"); + } + init { this._rawData.Set("dimension_value", value); } + } + + /// + /// Display name for this dimension value + /// + public required string DisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("display_name"); + } + 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.DimensionValue; + _ = this.DisplayName; + _ = this.UnitAmount; + } + + public MatrixWithDisplayNameConfigUnitAmount() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameConfigUnitAmount( + MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount + ) + : base(matrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameConfigUnitAmount(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameConfigUnitAmount(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameConfigUnitAmountFromRaw + : IFromRawJson +{ + /// + public MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithDisplayNameConversionRateConfigConverter))] +public record class MatrixWithDisplayNameConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithDisplayNameConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithDisplayNameConversionRateConfig(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 MatrixWithDisplayNameConversionRateConfig" + ); + } + } + + /// + /// 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 MatrixWithDisplayNameConversionRateConfig" + ), + }; + } + + public static implicit operator MatrixWithDisplayNameConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MatrixWithDisplayNameConversionRateConfig( + 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 MatrixWithDisplayNameConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MatrixWithDisplayNameConversionRateConfigConverter + : JsonConverter +{ + public override MatrixWithDisplayNameConversionRateConfig? 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 MatrixWithDisplayNameConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithDisplayNameConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredPackage : 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); } + } + + /// + /// Configuration for grouped_tiered_package pricing + /// + public required GroupedTieredPackageConfig GroupedTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_package_config" + ); + } + init { this._rawData.Set("grouped_tiered_package_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 GroupedTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.GroupedTieredPackageConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) + : base(groupedTieredPackage) { } +#pragma warning restore CS8618 + + public GroupedTieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedTieredPackageCadenceConverter))] +public enum GroupedTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedTieredPackageCadenceConverter : JsonConverter +{ + public override GroupedTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedTieredPackageCadence.Annual, + "semi_annual" => GroupedTieredPackageCadence.SemiAnnual, + "monthly" => GroupedTieredPackageCadence.Monthly, + "quarterly" => GroupedTieredPackageCadence.Quarterly, + "one_time" => GroupedTieredPackageCadence.OneTime, + "custom" => GroupedTieredPackageCadence.Custom, + _ => (GroupedTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedTieredPackageCadence.Annual => "annual", + GroupedTieredPackageCadence.SemiAnnual => "semi_annual", + GroupedTieredPackageCadence.Monthly => "monthly", + GroupedTieredPackageCadence.Quarterly => "quarterly", + GroupedTieredPackageCadence.OneTime => "one_time", + GroupedTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedTieredPackageConfig : JsonModel +{ + /// + /// The event property used to group before tiering + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public GroupedTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageConfig(GroupedTieredPackageConfig groupedTieredPackageConfig) + : base(groupedTieredPackageConfig) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageConfigFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredPackageConfigTier, + GroupedTieredPackageConfigTierFromRaw + >) +)] +public sealed record class GroupedTieredPackageConfigTier : JsonModel +{ + /// + /// Per package + /// + public required string PerUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit"); + } + init { this._rawData.Set("per_unit", value); } + } + + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.PerUnit; + _ = this.TierLowerBound; + } + + public GroupedTieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageConfigTier( + GroupedTieredPackageConfigTier groupedTieredPackageConfigTier + ) + : base(groupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredPackageLicenseAllocation, + GroupedTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class GroupedTieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public GroupedTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageLicenseAllocation( + GroupedTieredPackageLicenseAllocation groupedTieredPackageLicenseAllocation + ) + : base(groupedTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public GroupedTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedTieredPackageConversionRateConfigConverter))] +public record class GroupedTieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public GroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public GroupedTieredPackageConversionRateConfig(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 GroupedTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 GroupedTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator GroupedTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator GroupedTieredPackageConversionRateConfig( + 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 GroupedTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class GroupedTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override GroupedTieredPackageConversionRateConfig? 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 GroupedTieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + GroupedTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MaxGroupTieredPackage : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for max_group_tiered_package pricing + /// + public required MaxGroupTieredPackageConfig MaxGroupTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "max_group_tiered_package_config" + ); + } + init { this._rawData.Set("max_group_tiered_package_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 MaxGroupTieredPackageConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MaxGroupTieredPackageConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("max_group_tiered_package") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MaxGroupTieredPackage() + { + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) + : base(maxGroupTieredPackage) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackage(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackage(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackage FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackage.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MaxGroupTieredPackageCadenceConverter))] +public enum MaxGroupTieredPackageCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MaxGroupTieredPackageCadenceConverter : JsonConverter +{ + public override MaxGroupTieredPackageCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MaxGroupTieredPackageCadence.Annual, + "semi_annual" => MaxGroupTieredPackageCadence.SemiAnnual, + "monthly" => MaxGroupTieredPackageCadence.Monthly, + "quarterly" => MaxGroupTieredPackageCadence.Quarterly, + "one_time" => MaxGroupTieredPackageCadence.OneTime, + "custom" => MaxGroupTieredPackageCadence.Custom, + _ => (MaxGroupTieredPackageCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MaxGroupTieredPackageCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MaxGroupTieredPackageCadence.Annual => "annual", + MaxGroupTieredPackageCadence.SemiAnnual => "semi_annual", + MaxGroupTieredPackageCadence.Monthly => "monthly", + MaxGroupTieredPackageCadence.Quarterly => "quarterly", + MaxGroupTieredPackageCadence.OneTime => "one_time", + MaxGroupTieredPackageCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MaxGroupTieredPackageLicenseAllocation, + MaxGroupTieredPackageLicenseAllocationFromRaw + >) +)] +public sealed record class MaxGroupTieredPackageLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MaxGroupTieredPackageLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageLicenseAllocation( + MaxGroupTieredPackageLicenseAllocation maxGroupTieredPackageLicenseAllocation + ) + : base(maxGroupTieredPackageLicenseAllocation) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public MaxGroupTieredPackageLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for max_group_tiered_package pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class MaxGroupTieredPackageConfig : JsonModel +{ + /// + /// The event property used to group before tiering the group with the highest value + /// + 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("package_size"); + } + init { this._rawData.Set("package_size", value); } + } + + /// + /// Apply tiered pricing to the largest group after grouping with the provided key. + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public MaxGroupTieredPackageConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageConfig(MaxGroupTieredPackageConfig maxGroupTieredPackageConfig) + : base(maxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageConfigFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackageConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter< + MaxGroupTieredPackageConfigTier, + MaxGroupTieredPackageConfigTierFromRaw + >) +)] +public sealed record class MaxGroupTieredPackageConfigTier : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TierLowerBound; + _ = this.UnitAmount; + } + + public MaxGroupTieredPackageConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageConfigTier( + MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier + ) + : base(maxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageConfigTierFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackageConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MaxGroupTieredPackageConversionRateConfigConverter))] +public record class MaxGroupTieredPackageConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MaxGroupTieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MaxGroupTieredPackageConversionRateConfig(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 MaxGroupTieredPackageConversionRateConfig" + ); + } + } + + /// + /// 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 MaxGroupTieredPackageConversionRateConfig" + ), + }; + } + + public static implicit operator MaxGroupTieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MaxGroupTieredPackageConversionRateConfig( + 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 MaxGroupTieredPackageConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MaxGroupTieredPackageConversionRateConfigConverter + : JsonConverter +{ + public override MaxGroupTieredPackageConversionRateConfig? 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 MaxGroupTieredPackageConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MaxGroupTieredPackageConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class ScalableMatrixWithUnitPricing : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 scalable_matrix_with_unit_pricing pricing + /// + public required ScalableMatrixWithUnitPricingConfig 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); } + } + + /// + /// 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 ScalableMatrixWithUnitPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithUnitPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ScalableMatrixWithUnitPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricing( + ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing + ) + : base(scalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricing(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricing(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCadenceConverter))] +public enum ScalableMatrixWithUnitPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ScalableMatrixWithUnitPricingCadenceConverter + : JsonConverter +{ + public override ScalableMatrixWithUnitPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ScalableMatrixWithUnitPricingCadence.Annual, + "semi_annual" => ScalableMatrixWithUnitPricingCadence.SemiAnnual, + "monthly" => ScalableMatrixWithUnitPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithUnitPricingCadence.Quarterly, + "one_time" => ScalableMatrixWithUnitPricingCadence.OneTime, + "custom" => ScalableMatrixWithUnitPricingCadence.Custom, + _ => (ScalableMatrixWithUnitPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithUnitPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ScalableMatrixWithUnitPricingCadence.Annual => "annual", + ScalableMatrixWithUnitPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithUnitPricingCadence.Monthly => "monthly", + ScalableMatrixWithUnitPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithUnitPricingCadence.OneTime => "one_time", + ScalableMatrixWithUnitPricingCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithUnitPricingLicenseAllocation, + ScalableMatrixWithUnitPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ScalableMatrixWithUnitPricingLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ScalableMatrixWithUnitPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingLicenseAllocation( + ScalableMatrixWithUnitPricingLicenseAllocation scalableMatrixWithUnitPricingLicenseAllocation + ) + : base(scalableMatrixWithUnitPricingLicenseAllocation) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricingLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricingLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for scalable_matrix_with_unit_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithUnitPricingConfig, + ScalableMatrixWithUnitPricingConfigFromRaw + >) +)] +public sealed record class ScalableMatrixWithUnitPricingConfig : 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 + /// + public required IReadOnlyList MatrixScalingFactors + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "matrix_scaling_factors" + ); + } + init + { + this._rawData.Set>( + "matrix_scaling_factors", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The final unit price to rate against the output of the matrix + /// + public required string UnitPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_price"); + } + init { this._rawData.Set("unit_price", value); } + } + + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init { this._rawData.Set("prorate", value); } + } + + /// + /// Used to determine the unit rate (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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + _ = this.UnitPrice; + _ = this.GroupingKey; + _ = this.Prorate; + _ = this.SecondDimension; + } + + public ScalableMatrixWithUnitPricingConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingConfig( + ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig + ) + : base(scalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricingConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricingConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingConfigFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricingConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixScalingFactor : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public MatrixScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixScalingFactor(MatrixScalingFactor matrixScalingFactor) + : base(matrixScalingFactor) { } +#pragma warning restore CS8618 + + public MatrixScalingFactor(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixScalingFactor(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixScalingFactorFromRaw : IFromRawJson +{ + /// + public MatrixScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixScalingFactor.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ScalableMatrixWithUnitPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithUnitPricingConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithUnitPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithUnitPricingConversionRateConfig(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 ScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ScalableMatrixWithUnitPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + 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 ScalableMatrixWithUnitPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter + : JsonConverter +{ + public override ScalableMatrixWithUnitPricingConversionRateConfig? 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 ScalableMatrixWithUnitPricingConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithUnitPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricing, + ScalableMatrixWithTieredPricingFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricing : 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 scalable_matrix_with_tiered_pricing pricing + /// + public required ScalableMatrixWithTieredPricingConfig 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); } + } + + /// + /// 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 ScalableMatrixWithTieredPricingConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.ScalableMatrixWithTieredPricingConfig.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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public ScalableMatrixWithTieredPricing() + { + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricing( + ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing + ) + : base(scalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricing(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricing(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingFromRaw : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricing FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCadenceConverter))] +public enum ScalableMatrixWithTieredPricingCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ScalableMatrixWithTieredPricingCadenceConverter + : JsonConverter +{ + public override ScalableMatrixWithTieredPricingCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ScalableMatrixWithTieredPricingCadence.Annual, + "semi_annual" => ScalableMatrixWithTieredPricingCadence.SemiAnnual, + "monthly" => ScalableMatrixWithTieredPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithTieredPricingCadence.Quarterly, + "one_time" => ScalableMatrixWithTieredPricingCadence.OneTime, + "custom" => ScalableMatrixWithTieredPricingCadence.Custom, + _ => (ScalableMatrixWithTieredPricingCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithTieredPricingCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ScalableMatrixWithTieredPricingCadence.Annual => "annual", + ScalableMatrixWithTieredPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithTieredPricingCadence.Monthly => "monthly", + ScalableMatrixWithTieredPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithTieredPricingCadence.OneTime => "one_time", + ScalableMatrixWithTieredPricingCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingLicenseAllocation, + ScalableMatrixWithTieredPricingLicenseAllocationFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ScalableMatrixWithTieredPricingLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingLicenseAllocation( + ScalableMatrixWithTieredPricingLicenseAllocation scalableMatrixWithTieredPricingLicenseAllocation + ) + : base(scalableMatrixWithTieredPricingLicenseAllocation) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for scalable_matrix_with_tiered_pricing pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfig, + ScalableMatrixWithTieredPricingConfigFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfig : JsonModel +{ + /// + /// Used for the scalable matrix first dimension + /// + 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 + >("matrix_scaling_factors"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); + } + } + + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(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() + { + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.SecondDimension; + } + + public ScalableMatrixWithTieredPricingConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfig( + ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig + ) + : base(scalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single matrix scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor, + ScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfigMatrixScalingFactor : 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("scaling_factor"); + } + init { this._rawData.Set("scaling_factor", value); } + } + + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } + + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; + } + + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) + : base(scalableMatrixWithTieredPricingConfigMatrixScalingFactor) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tier entry with business logic +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingConfigTier, + ScalableMatrixWithTieredPricingConfigTierFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingConfigTier : 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 ScalableMatrixWithTieredPricingConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingConfigTier( + ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier + ) + : base(scalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingConfigTierFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(ScalableMatrixWithTieredPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithTieredPricingConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithTieredPricingConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ScalableMatrixWithTieredPricingConversionRateConfig(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 ScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + } + + /// + /// 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 ScalableMatrixWithTieredPricingConversionRateConfig" + ), + }; + } + + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + 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 ScalableMatrixWithTieredPricingConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter + : JsonConverter +{ + public override ScalableMatrixWithTieredPricingConversionRateConfig? 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 ScalableMatrixWithTieredPricingConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithTieredPricingConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CumulativeGroupedBulk : 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); } + } + + /// + /// Configuration for cumulative_grouped_bulk pricing + /// + public required CumulativeGroupedBulkConfig CumulativeGroupedBulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_bulk_config" + ); + } + init { this._rawData.Set("cumulative_grouped_bulk_config", 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 CumulativeGroupedBulkConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedBulkConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_bulk") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public CumulativeGroupedBulk() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) + : base(cumulativeGroupedBulk) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulk(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulk(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedBulk FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulk.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CumulativeGroupedBulkCadenceConverter))] +public enum CumulativeGroupedBulkCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CumulativeGroupedBulkCadenceConverter : JsonConverter +{ + public override CumulativeGroupedBulkCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => CumulativeGroupedBulkCadence.Annual, + "semi_annual" => CumulativeGroupedBulkCadence.SemiAnnual, + "monthly" => CumulativeGroupedBulkCadence.Monthly, + "quarterly" => CumulativeGroupedBulkCadence.Quarterly, + "one_time" => CumulativeGroupedBulkCadence.OneTime, + "custom" => CumulativeGroupedBulkCadence.Custom, + _ => (CumulativeGroupedBulkCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedBulkCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + CumulativeGroupedBulkCadence.Annual => "annual", + CumulativeGroupedBulkCadence.SemiAnnual => "semi_annual", + CumulativeGroupedBulkCadence.Monthly => "monthly", + CumulativeGroupedBulkCadence.Quarterly => "quarterly", + CumulativeGroupedBulkCadence.OneTime => "one_time", + CumulativeGroupedBulkCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_bulk pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CumulativeGroupedBulkConfig : JsonModel +{ + /// + /// Each tier lower bound must have the same group of values. + /// + public required IReadOnlyList DimensionValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "dimension_values" + ); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required string Group + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group"); + } + init { this._rawData.Set("group", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.DimensionValues) + { + item.Validate(); + } + _ = this.Group; + } + + public CumulativeGroupedBulkConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkConfig(CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig) + : base(cumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulkConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkConfigFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a dimension value entry +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DimensionValue : JsonModel +{ + /// + /// Grouping key value + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// 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 + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public DimensionValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DimensionValue(DimensionValue dimensionValue) + : base(dimensionValue) { } +#pragma warning restore CS8618 + + public DimensionValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DimensionValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DimensionValue FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DimensionValueFromRaw : IFromRawJson +{ + /// + public DimensionValue FromRawUnchecked(IReadOnlyDictionary rawData) => + DimensionValue.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedBulkLicenseAllocation, + CumulativeGroupedBulkLicenseAllocationFromRaw + >) +)] +public sealed record class CumulativeGroupedBulkLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public CumulativeGroupedBulkLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkLicenseAllocation( + CumulativeGroupedBulkLicenseAllocation cumulativeGroupedBulkLicenseAllocation + ) + : base(cumulativeGroupedBulkLicenseAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulkLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedBulkLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(CumulativeGroupedBulkConversionRateConfigConverter))] +public record class CumulativeGroupedBulkConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedBulkConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedBulkConversionRateConfig(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 CumulativeGroupedBulkConversionRateConfig" + ); + } + } + + /// + /// 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 CumulativeGroupedBulkConversionRateConfig" + ), + }; + } + + public static implicit operator CumulativeGroupedBulkConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator CumulativeGroupedBulkConversionRateConfig( + 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 CumulativeGroupedBulkConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class CumulativeGroupedBulkConversionRateConfigConverter + : JsonConverter +{ + public override CumulativeGroupedBulkConversionRateConfig? 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 CumulativeGroupedBulkConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedBulkConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CumulativeGroupedAllocation : 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); } + } + + /// + /// 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 CumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public CumulativeGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + CumulativeGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationConfig : JsonModel +{ + /// + /// The overall allocation across all groups + /// + public required string CumulativeAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cumulative_allocation"); + } + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", 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.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } + + public CumulativeGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationLicenseAllocation, + CumulativeGroupedAllocationLicenseAllocationFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public CumulativeGroupedAllocationLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationLicenseAllocation( + CumulativeGroupedAllocationLicenseAllocation cumulativeGroupedAllocationLicenseAllocation + ) + : base(cumulativeGroupedAllocationLicenseAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocationLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocationLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedAllocationLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig(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 CumulativeGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// 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 CumulativeGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + 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 CumulativeGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationConversionRateConfig? 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 CumulativeGroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MinimumComposite : 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); } + } + + /// + /// 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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Configuration for minimum_composite pricing + /// + public required MinimumCompositeConfig MinimumCompositeConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "minimum_composite_config" + ); + } + init { this._rawData.Set("minimum_composite_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 MinimumCompositeConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + this.MinimumCompositeConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("minimum_composite") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MinimumComposite() + { + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumComposite(MinimumComposite minimumComposite) + : base(minimumComposite) { } +#pragma warning restore CS8618 + + public MinimumComposite(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("minimum_composite"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumComposite(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumComposite FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MinimumCompositeFromRaw : IFromRawJson +{ + /// + public MinimumComposite FromRawUnchecked(IReadOnlyDictionary rawData) => + MinimumComposite.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MinimumCompositeCadenceConverter))] +public enum MinimumCompositeCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MinimumCompositeCadenceConverter : JsonConverter +{ + public override MinimumCompositeCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MinimumCompositeCadence.Annual, + "semi_annual" => MinimumCompositeCadence.SemiAnnual, + "monthly" => MinimumCompositeCadence.Monthly, + "quarterly" => MinimumCompositeCadence.Quarterly, + "one_time" => MinimumCompositeCadence.OneTime, + "custom" => MinimumCompositeCadence.Custom, + _ => (MinimumCompositeCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MinimumCompositeCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MinimumCompositeCadence.Annual => "annual", + MinimumCompositeCadence.SemiAnnual => "semi_annual", + MinimumCompositeCadence.Monthly => "monthly", + MinimumCompositeCadence.Quarterly => "quarterly", + MinimumCompositeCadence.OneTime => "one_time", + MinimumCompositeCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MinimumCompositeLicenseAllocation, + MinimumCompositeLicenseAllocationFromRaw + >) +)] +public sealed record class MinimumCompositeLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public MinimumCompositeLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumCompositeLicenseAllocation( + MinimumCompositeLicenseAllocation minimumCompositeLicenseAllocation + ) + : base(minimumCompositeLicenseAllocation) { } +#pragma warning restore CS8618 + + public MinimumCompositeLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumCompositeLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MinimumCompositeLicenseAllocationFromRaw : IFromRawJson +{ + /// + public MinimumCompositeLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MinimumCompositeLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for minimum_composite pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MinimumCompositeConfig : 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 MinimumCompositeConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumCompositeConfig(MinimumCompositeConfig minimumCompositeConfig) + : base(minimumCompositeConfig) { } +#pragma warning restore CS8618 + + public MinimumCompositeConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MinimumCompositeConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public MinimumCompositeConfig(string minimumAmount) + : this() + { + this.MinimumAmount = minimumAmount; + } +} + +class MinimumCompositeConfigFromRaw : IFromRawJson +{ + /// + public MinimumCompositeConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MinimumCompositeConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MinimumCompositeConversionRateConfigConverter))] +public record class MinimumCompositeConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MinimumCompositeConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MinimumCompositeConversionRateConfig(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 MinimumCompositeConversionRateConfig" + ); + } + } + + /// + /// 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 MinimumCompositeConversionRateConfig" + ), + }; + } + + public static implicit operator MinimumCompositeConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MinimumCompositeConversionRateConfig( + 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 MinimumCompositeConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MinimumCompositeConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MinimumCompositeConversionRateConfigConverter + : JsonConverter +{ + public override MinimumCompositeConversionRateConfig? 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 MinimumCompositeConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MinimumCompositeConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +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>("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); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 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 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public Percent() + { + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) + : base(percent) { } +#pragma warning restore CS8618 + + 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 Percent FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PercentFromRaw : IFromRawJson +{ + /// + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PercentCadenceConverter : JsonConverter +{ + public override PercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + PercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PercentLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public PercentLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentLicenseAllocation(PercentLicenseAllocation percentLicenseAllocation) + : base(percentLicenseAllocation) { } +#pragma warning restore CS8618 + + public PercentLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PercentLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PercentLicenseAllocationFromRaw : IFromRawJson +{ + /// + public PercentLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PercentLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// Configuration for percent pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } +#pragma warning restore CS8618 + + 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 PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PercentConfig(double percent) + : this() + { + this.Percent = percent; + } +} + +class PercentConfigFromRaw : IFromRawJson +{ + /// + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(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 PercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator 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(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PercentConversionRateConfigConverter : JsonConverter +{ + public override 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 PercentConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PercentConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +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>("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. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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 EventOutputConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_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`. + /// + 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; + foreach (var item in this.LicenseAllocations) + { + item.Validate(); + } + 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.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public EventOutput() + { + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } +#pragma warning restore CS8618 + + public EventOutput(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + EventOutput(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class EventOutputFromRaw : IFromRawJson +{ + /// + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class EventOutputCadenceConverter : JsonConverter +{ + public override EventOutputCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + EventOutputCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for event_output pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel +{ + /// + /// The key in the event data to extract the unit rate from. + /// + public required string UnitRatingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + 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.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; + } + + public EventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } +#pragma warning restore CS8618 + + 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 EventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public EventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +class EventOutputConfigFromRaw : IFromRawJson +{ + /// + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class EventOutputLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public EventOutputLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputLicenseAllocation(EventOutputLicenseAllocation eventOutputLicenseAllocation) + : base(eventOutputLicenseAllocation) { } +#pragma warning restore CS8618 + + public EventOutputLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + EventOutputLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static EventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class EventOutputLicenseAllocationFromRaw : IFromRawJson +{ + /// + public EventOutputLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => EventOutputLicenseAllocation.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(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 + ) + { + this.Value = value; + this._element = element; + } + + public EventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public EventOutputConversionRateConfig(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 EventOutputConversionRateConfig" + ); + } + } + + /// + /// 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 EventOutputConversionRateConfig" + ), + }; + } + + public static implicit operator EventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator EventOutputConversionRateConfig( + 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 EventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class EventOutputConversionRateConfigConverter + : JsonConverter +{ + public override EventOutputConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); } - init { this._rawData.Set("plan_phase_order", value); } - } - - /// - /// New plan price request body params. - /// - public PricePrice? PriceValue - { - get + catch { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + conversionRateType = null; } - init { this._rawData.Set("price", value); } - } - - /// - public override void Validate() - { - this.AllocationPrice?.Validate(); - _ = this.PlanPhaseOrder; - this.PriceValue?.Validate(); - } - - public Price() { } -#pragma warning disable CS8618 - [SetsRequiredMembers] - public Price(Price price) - : base(price) { } -#pragma warning restore CS8618 + 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 + } - public Price(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } + 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 + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - Price(FrozenDictionary rawData) - { - this._rawData = new(rawData); + return new(element); + } + default: + { + return new EventOutputConversionRateConfig(element); + } + } } -#pragma warning restore CS8618 - /// - public static Price FromRawUnchecked(IReadOnlyDictionary rawData) + public override void Write( + Utf8JsonWriter writer, + EventOutputConversionRateConfig value, + JsonSerializerOptions options + ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + JsonSerializer.Serialize(writer, value.Json, options); } } -class PriceFromRaw : IFromRawJson -{ - /// - public Price FromRawUnchecked(IReadOnlyDictionary rawData) => - Price.FromRawUnchecked(rawData); -} - /// /// New plan price request body params. /// @@ -987,7 +33187,7 @@ public PricePrice(NewPlanBulkPrice value, JsonElement? element = null) this._element = element; } - public PricePrice(BulkWithFilters value, JsonElement? element = null) + public PricePrice(PricePriceBulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1053,7 +33253,7 @@ public PricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = this._element = element; } - public PricePrice(TieredWithProration value, JsonElement? element = null) + public PricePrice(PricePriceTieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1089,7 +33289,7 @@ public PricePrice(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? elem this._element = element; } - public PricePrice(GroupedWithMinMaxThresholds value, JsonElement? element = null) + public PricePrice(PricePriceGroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1134,7 +33334,7 @@ public PricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element this._element = element; } - public PricePrice(CumulativeGroupedAllocation value, JsonElement? element = null) + public PricePrice(PricePriceCumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1146,13 +33346,13 @@ public PricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = nul this._element = element; } - public PricePrice(Percent value, JsonElement? element = null) + public PricePrice(PricePricePercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(EventOutput value, JsonElement? element = null) + public PricePrice(PricePriceEventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1228,22 +33428,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 `BulkWithFilters` + /// // `value` is of type `PricePriceBulkWithFilters` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) + public bool TryPickBulkWithFilters([NotNullWhen(true)] out PricePriceBulkWithFilters? value) { - value = this.Value as BulkWithFilters; + value = this.Value as PricePriceBulkWithFilters; return value != null; } @@ -1475,22 +33675,24 @@ 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 `TieredWithProration` + /// // `value` is of type `PricePriceTieredWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out PricePriceTieredWithProration? value + ) { - value = this.Value as TieredWithProration; + value = this.Value as PricePriceTieredWithProration; return value != null; } @@ -1611,24 +33813,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 `GroupedWithMinMaxThresholds` + /// // `value` is of type `PricePriceGroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value + [NotNullWhen(true)] out PricePriceGroupedWithMinMaxThresholds? value ) { - value = this.Value as GroupedWithMinMaxThresholds; + value = this.Value as PricePriceGroupedWithMinMaxThresholds; return value != null; } @@ -1772,24 +33974,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 `CumulativeGroupedAllocation` + /// // `value` is of type `PricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out CumulativeGroupedAllocation? value + [NotNullWhen(true)] out PricePriceCumulativeGroupedAllocation? value ) { - value = this.Value as CumulativeGroupedAllocation; + value = this.Value as PricePriceCumulativeGroupedAllocation; return value != null; } @@ -1818,43 +34020,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 `Percent` + /// // `value` is of type `PricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent([NotNullWhen(true)] out Percent? value) + public bool TryPickPercent([NotNullWhen(true)] out PricePricePercent? value) { - value = this.Value as Percent; + value = this.Value as PricePricePercent; 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 `EventOutput` + /// // `value` is of type `PricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) + public bool TryPickEventOutput([NotNullWhen(true)] out PricePriceEventOutput? value) { - value = this.Value as EventOutput; + value = this.Value as PricePriceEventOutput; return value != null; } @@ -1875,7 +34077,7 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (BulkWithFilters value) => {...}, + /// (PricePriceBulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -1886,23 +34088,23 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (TieredWithProration value) => {...}, + /// (PricePriceTieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (GroupedWithMinMaxThresholds value) => {...}, + /// (PricePriceGroupedWithMinMaxThresholds value) => {...}, /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, /// (NewPlanGroupedTieredPackagePrice value) => {...}, /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (CumulativeGroupedAllocation value) => {...}, + /// (PricePriceCumulativeGroupedAllocation value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (Percent value) => {...}, - /// (EventOutput value) => {...} + /// (PricePricePercent value) => {...}, + /// (PricePriceEventOutput value) => {...} /// ); /// /// @@ -1911,7 +34113,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, @@ -1922,23 +34124,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 cumulativeGroupedAllocation, System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -1952,7 +34154,7 @@ public void Switch( case NewPlanBulkPrice value: newPlanBulk(value); break; - case BulkWithFilters value: + case PricePriceBulkWithFilters value: bulkWithFilters(value); break; case NewPlanPackagePrice value: @@ -1985,7 +34187,7 @@ public void Switch( case NewPlanMatrixWithAllocationPrice value: newPlanMatrixWithAllocation(value); break; - case TieredWithProration value: + case PricePriceTieredWithProration value: tieredWithProration(value); break; case NewPlanUnitWithProrationPrice value: @@ -2003,7 +34205,7 @@ public void Switch( case NewPlanGroupedWithMeteredMinimumPrice value: newPlanGroupedWithMeteredMinimum(value); break; - case GroupedWithMinMaxThresholds value: + case PricePriceGroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; case NewPlanMatrixWithDisplayNamePrice value: @@ -2024,16 +34226,16 @@ public void Switch( case NewPlanCumulativeGroupedBulkPrice value: newPlanCumulativeGroupedBulk(value); break; - case CumulativeGroupedAllocation value: + case PricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; case NewPlanMinimumCompositePrice value: newPlanMinimumComposite(value); break; - case Percent value: + case PricePricePercent value: percent(value); break; - case EventOutput value: + case PricePriceEventOutput value: eventOutput(value); break; default: @@ -2059,7 +34261,7 @@ public void Switch( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (BulkWithFilters value) => {...}, + /// (PricePriceBulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -2070,23 +34272,23 @@ public void Switch( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (TieredWithProration value) => {...}, + /// (PricePriceTieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (GroupedWithMinMaxThresholds value) => {...}, + /// (PricePriceGroupedWithMinMaxThresholds value) => {...}, /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, /// (NewPlanGroupedTieredPackagePrice value) => {...}, /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (CumulativeGroupedAllocation value) => {...}, + /// (PricePriceCumulativeGroupedAllocation value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (Percent value) => {...}, - /// (EventOutput value) => {...} + /// (PricePricePercent value) => {...}, + /// (PricePriceEventOutput value) => {...} /// ); /// /// @@ -2095,7 +34297,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, @@ -2106,13 +34308,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 groupedWithMinMaxThresholds, + System::Func groupedWithMinMaxThresholds, System::Func newPlanMatrixWithDisplayName, System::Func newPlanGroupedTieredPackage, System::Func newPlanMaxGroupTieredPackage, @@ -2125,10 +34327,10 @@ public T Match( T > newPlanScalableMatrixWithTieredPricing, System::Func newPlanCumulativeGroupedBulk, - System::Func cumulativeGroupedAllocation, + System::Func cumulativeGroupedAllocation, System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -2136,7 +34338,7 @@ public T Match( NewPlanUnitPrice value => newPlanUnit(value), NewPlanTieredPrice value => newPlanTiered(value), NewPlanBulkPrice value => newPlanBulk(value), - BulkWithFilters value => bulkWithFilters(value), + PricePriceBulkWithFilters value => bulkWithFilters(value), NewPlanPackagePrice value => newPlanPackage(value), NewPlanMatrixPrice value => newPlanMatrix(value), NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), @@ -2147,7 +34349,7 @@ public T Match( NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - TieredWithProration value => tieredWithProration(value), + PricePriceTieredWithProration value => tieredWithProration(value), NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), @@ -2155,7 +34357,7 @@ public T Match( value ), NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), + PricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), @@ -2165,10 +34367,10 @@ public T Match( NewPlanScalableMatrixWithTieredPricingPrice value => newPlanScalableMatrixWithTieredPricing(value), NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), + PricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - Percent value => percent(value), - EventOutput value => eventOutput(value), + PricePricePercent value => percent(value), + PricePriceEventOutput value => eventOutput(value), _ => throw new OrbInvalidDataException("Data did not match any variant of PricePrice"), }; } @@ -2179,7 +34381,7 @@ public T Match( public static implicit operator PricePrice(NewPlanBulkPrice value) => new(value); - public static implicit operator PricePrice(BulkWithFilters value) => new(value); + public static implicit operator PricePrice(PricePriceBulkWithFilters value) => new(value); public static implicit operator PricePrice(NewPlanPackagePrice value) => new(value); @@ -2205,7 +34407,7 @@ public static implicit operator PricePrice(NewPlanPackageWithAllocationPrice val public static implicit operator PricePrice(NewPlanMatrixWithAllocationPrice value) => new(value); - public static implicit operator PricePrice(TieredWithProration value) => new(value); + public static implicit operator PricePrice(PricePriceTieredWithProration value) => new(value); public static implicit operator PricePrice(NewPlanUnitWithProrationPrice value) => new(value); @@ -2219,7 +34421,8 @@ public static implicit operator PricePrice(NewPlanGroupedWithProratedMinimumPric public static implicit operator PricePrice(NewPlanGroupedWithMeteredMinimumPrice value) => new(value); - public static implicit operator PricePrice(GroupedWithMinMaxThresholds value) => new(value); + public static implicit operator PricePrice(PricePriceGroupedWithMinMaxThresholds value) => + new(value); public static implicit operator PricePrice(NewPlanMatrixWithDisplayNamePrice value) => new(value); @@ -2239,13 +34442,14 @@ public static implicit operator PricePrice(NewPlanScalableMatrixWithTieredPricin public static implicit operator PricePrice(NewPlanCumulativeGroupedBulkPrice value) => new(value); - public static implicit operator PricePrice(CumulativeGroupedAllocation value) => new(value); + public static implicit operator PricePrice(PricePriceCumulativeGroupedAllocation value) => + new(value); public static implicit operator PricePrice(NewPlanMinimumCompositePrice value) => new(value); - public static implicit operator PricePrice(Percent value) => new(value); + public static implicit operator PricePrice(PricePricePercent value) => new(value); - public static implicit operator PricePrice(EventOutput value) => new(value); + public static implicit operator PricePrice(PricePriceEventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2323,7 +34527,7 @@ int VariantIndex() NewPlanUnitPrice _ => 0, NewPlanTieredPrice _ => 1, NewPlanBulkPrice _ => 2, - BulkWithFilters _ => 3, + PricePriceBulkWithFilters _ => 3, NewPlanPackagePrice _ => 4, NewPlanMatrixPrice _ => 5, NewPlanThresholdTotalAmountPrice _ => 6, @@ -2334,23 +34538,23 @@ int VariantIndex() NewPlanPackageWithAllocationPrice _ => 11, NewPlanUnitWithPercentPrice _ => 12, NewPlanMatrixWithAllocationPrice _ => 13, - TieredWithProration _ => 14, + PricePriceTieredWithProration _ => 14, NewPlanUnitWithProrationPrice _ => 15, NewPlanGroupedAllocationPrice _ => 16, NewPlanBulkWithProrationPrice _ => 17, NewPlanGroupedWithProratedMinimumPrice _ => 18, NewPlanGroupedWithMeteredMinimumPrice _ => 19, - GroupedWithMinMaxThresholds _ => 20, + PricePriceGroupedWithMinMaxThresholds _ => 20, NewPlanMatrixWithDisplayNamePrice _ => 21, NewPlanGroupedTieredPackagePrice _ => 22, NewPlanMaxGroupTieredPackagePrice _ => 23, NewPlanScalableMatrixWithUnitPricingPrice _ => 24, NewPlanScalableMatrixWithTieredPricingPrice _ => 25, NewPlanCumulativeGroupedBulkPrice _ => 26, - CumulativeGroupedAllocation _ => 27, + PricePriceCumulativeGroupedAllocation _ => 27, NewPlanMinimumCompositePrice _ => 28, - Percent _ => 29, - EventOutput _ => 30, + PricePricePercent _ => 29, + PricePriceEventOutput _ => 30, _ => -1, }; } @@ -2447,7 +34651,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2691,7 +34895,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2825,10 +35029,11 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2984,10 +35189,11 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3028,7 +35234,10 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize(element, options); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3047,7 +35256,10 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize(element, options); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3079,18 +35291,22 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class BulkWithFilters : JsonModel +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PricePriceBulkWithFilters : JsonModel { /// /// Configuration for bulk_with_filters pricing /// - public required BulkWithFiltersConfig BulkWithFiltersConfig + public required PricePriceBulkWithFiltersBulkWithFiltersConfig 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); } } @@ -3098,12 +35314,14 @@ public required BulkWithFiltersConfig BulkWithFiltersConfig /// /// 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); } } @@ -3206,12 +35424,14 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ConversionRateConfig? ConversionRateConfig + public PricePriceBulkWithFiltersConversionRateConfig? 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); } } @@ -3380,18 +35600,18 @@ public override void Validate() _ = this.ReferenceID; } - public BulkWithFilters() + public PricePriceBulkWithFilters() { this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public BulkWithFilters(BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } + public PricePriceBulkWithFilters(PricePriceBulkWithFilters pricePriceBulkWithFilters) + : base(pricePriceBulkWithFilters) { } #pragma warning restore CS8618 - public BulkWithFilters(IReadOnlyDictionary rawData) + public PricePriceBulkWithFilters(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -3400,45 +35620,55 @@ public BulkWithFilters(IReadOnlyDictionary rawData) #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFilters(FrozenDictionary rawData) + PricePriceBulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static PricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class PricePriceBulkWithFiltersFromRaw : IFromRawJson { /// - public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => - BulkWithFilters.FromRawUnchecked(rawData); + public PricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePriceBulkWithFilters.FromRawUnchecked(rawData); } /// /// Configuration for bulk_with_filters pricing /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class BulkWithFiltersConfig : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + PricePriceBulkWithFiltersBulkWithFiltersConfig, + PricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class PricePriceBulkWithFiltersBulkWithFiltersConfig : 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< + ImmutableArray + >("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -3448,16 +35678,18 @@ public required IReadOnlyList Filters /// /// 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< + ImmutableArray + >("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -3477,29 +35709,33 @@ public override void Validate() } } - public BulkWithFiltersConfig() { } + public PricePriceBulkWithFiltersBulkWithFiltersConfig() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) - : base(bulkWithFiltersConfig) { } + public PricePriceBulkWithFiltersBulkWithFiltersConfig( + PricePriceBulkWithFiltersBulkWithFiltersConfig pricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(pricePriceBulkWithFiltersBulkWithFiltersConfig) { } #pragma warning restore CS8618 - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) + public PricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) + PricePriceBulkWithFiltersBulkWithFiltersConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static BulkWithFiltersConfig FromRawUnchecked( + /// + public static PricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3507,19 +35743,25 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersConfigFromRaw : IFromRawJson +class PricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson { /// - public BulkWithFiltersConfig FromRawUnchecked( + public PricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); + ) => PricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single property filter /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Filter : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + PricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + PricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class PricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel { /// /// Event property key to filter on @@ -3554,46 +35796,61 @@ public override void Validate() _ = this.PropertyValue; } - public Filter() { } + public PricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public Filter(Filter filter) - : base(filter) { } + public PricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + PricePriceBulkWithFiltersBulkWithFiltersConfigFilter pricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(pricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } #pragma warning restore CS8618 - public Filter(IReadOnlyDictionary rawData) + public PricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Filter(FrozenDictionary rawData) + PricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static PricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class PricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson { /// - public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => - Filter.FromRawUnchecked(rawData); + public PricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); } /// /// Configuration for a single bulk pricing tier /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Tier : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + PricePriceBulkWithFiltersBulkWithFiltersConfigTier, + PricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class PricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel { /// /// Amount per unit @@ -3628,53 +35885,63 @@ public override void Validate() _ = this.TierLowerBound; } - public Tier() { } + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public Tier(Tier tier) - : base(tier) { } + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier( + PricePriceBulkWithFiltersBulkWithFiltersConfigTier pricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(pricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } #pragma warning restore CS8618 - public Tier(IReadOnlyDictionary rawData) + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Tier(FrozenDictionary rawData) + PricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static PricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public Tier(string unitAmount) + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) : this() { this.UnitAmount = unitAmount; } } -class TierFromRaw : IFromRawJson +class PricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson { /// - public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => - Tier.FromRawUnchecked(rawData); + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(CadenceConverter))] -public enum Cadence +[JsonConverter(typeof(PricePriceBulkWithFiltersCadenceConverter))] +public enum PricePriceBulkWithFiltersCadence { Annual, SemiAnnual, @@ -3684,9 +35951,10 @@ public enum Cadence Custom, } -sealed class CadenceConverter : JsonConverter +sealed class PricePriceBulkWithFiltersCadenceConverter + : JsonConverter { - public override Cadence Read( + public override PricePriceBulkWithFiltersCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -3694,28 +35962,32 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => Cadence.Annual, - "semi_annual" => Cadence.SemiAnnual, - "monthly" => Cadence.Monthly, - "quarterly" => Cadence.Quarterly, - "one_time" => Cadence.OneTime, - "custom" => Cadence.Custom, - _ => (Cadence)(-1), + "annual" => PricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => PricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => PricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => PricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => PricePriceBulkWithFiltersCadence.OneTime, + "custom" => PricePriceBulkWithFiltersCadence.Custom, + _ => (PricePriceBulkWithFiltersCadence)(-1), }; } - public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) + public override void Write( + Utf8JsonWriter writer, + PricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) { JsonSerializer.Serialize( writer, value switch { - Cadence.Annual => "annual", - Cadence.SemiAnnual => "semi_annual", - Cadence.Monthly => "monthly", - Cadence.Quarterly => "quarterly", - Cadence.OneTime => "one_time", - Cadence.Custom => "custom", + PricePriceBulkWithFiltersCadence.Annual => "annual", + PricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", + PricePriceBulkWithFiltersCadence.Monthly => "monthly", + PricePriceBulkWithFiltersCadence.Quarterly => "quarterly", + PricePriceBulkWithFiltersCadence.OneTime => "one_time", + PricePriceBulkWithFiltersCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -3725,8 +35997,8 @@ public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerO } } -[JsonConverter(typeof(ConversionRateConfigConverter))] -public record class ConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class PricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -3743,19 +36015,25 @@ public JsonElement Json } } - public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) + public PricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) + public PricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ConversionRateConfig(JsonElement element) + public PricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -3837,7 +36115,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + "Data did not match any variant of PricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -3873,16 +36151,18 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + "Data did not match any variant of PricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => - new(value); + public static implicit operator PricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - public static implicit operator ConversionRateConfig(SharedTieredConversionRateConfig value) => - new(value); + public static implicit operator PricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3899,13 +36179,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + "Data did not match any variant of PricePriceBulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ConversionRateConfig? other) => + public virtual bool Equals(PricePriceBulkWithFiltersConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -3932,9 +36212,10 @@ int VariantIndex() } } -sealed class ConversionRateConfigConverter : JsonConverter +sealed class PricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override ConversionRateConfig? Read( + public override PricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -3999,14 +36280,14 @@ JsonSerializerOptions options } default: { - return new ConversionRateConfig(element); + return new PricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ConversionRateConfig value, + PricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -4014,20 +36295,22 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class TieredWithProration : JsonModel +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PricePriceTieredWithProration : 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); } } @@ -4074,12 +36357,12 @@ public required string Name /// /// Configuration for tiered_with_proration pricing /// - public required TieredWithProrationConfig TieredWithProrationConfig + public required PricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_with_proration_config" ); } @@ -4145,12 +36428,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public TieredWithProrationConversionRateConfig? ConversionRateConfig + public PricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4321,18 +36604,20 @@ public override void Validate() _ = this.ReferenceID; } - public TieredWithProration() + public PricePriceTieredWithProration() { this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public TieredWithProration(TieredWithProration tieredWithProration) - : base(tieredWithProration) { } + public PricePriceTieredWithProration( + PricePriceTieredWithProration pricePriceTieredWithProration + ) + : base(pricePriceTieredWithProration) { } #pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public PricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -4341,14 +36626,14 @@ public TieredWithProration(IReadOnlyDictionary rawData) #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + PricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProration FromRawUnchecked( + /// + public static PricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4356,18 +36641,19 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw : IFromRawJson +class PricePriceTieredWithProrationFromRaw : IFromRawJson { /// - public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => - TieredWithProration.FromRawUnchecked(rawData); + public PricePriceTieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(PricePriceTieredWithProrationCadenceConverter))] +public enum PricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -4377,9 +36663,10 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter : JsonConverter +sealed class PricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override TieredWithProrationCadence Read( + public override PricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4387,19 +36674,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => TieredWithProrationCadence.Annual, - "semi_annual" => TieredWithProrationCadence.SemiAnnual, - "monthly" => TieredWithProrationCadence.Monthly, - "quarterly" => TieredWithProrationCadence.Quarterly, - "one_time" => TieredWithProrationCadence.OneTime, - "custom" => TieredWithProrationCadence.Custom, - _ => (TieredWithProrationCadence)(-1), + "annual" => PricePriceTieredWithProrationCadence.Annual, + "semi_annual" => PricePriceTieredWithProrationCadence.SemiAnnual, + "monthly" => PricePriceTieredWithProrationCadence.Monthly, + "quarterly" => PricePriceTieredWithProrationCadence.Quarterly, + "one_time" => PricePriceTieredWithProrationCadence.OneTime, + "custom" => PricePriceTieredWithProrationCadence.Custom, + _ => (PricePriceTieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - TieredWithProrationCadence value, + PricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -4407,12 +36694,12 @@ JsonSerializerOptions options writer, value switch { - TieredWithProrationCadence.Annual => "annual", - TieredWithProrationCadence.SemiAnnual => "semi_annual", - TieredWithProrationCadence.Monthly => "monthly", - TieredWithProrationCadence.Quarterly => "quarterly", - TieredWithProrationCadence.OneTime => "one_time", - TieredWithProrationCadence.Custom => "custom", + PricePriceTieredWithProrationCadence.Annual => "annual", + PricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + PricePriceTieredWithProrationCadence.Monthly => "monthly", + PricePriceTieredWithProrationCadence.Quarterly => "quarterly", + PricePriceTieredWithProrationCadence.OneTime => "one_time", + PricePriceTieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4426,29 +36713,31 @@ JsonSerializerOptions options /// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + PricePriceTieredWithProrationTieredWithProrationConfig, + PricePriceTieredWithProrationTieredWithProrationConfigFromRaw + >) )] -public sealed record class TieredWithProrationConfig : JsonModel +public sealed record class PricePriceTieredWithProrationTieredWithProrationConfig : 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>( - "tiers" - ); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); } init { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } } @@ -4461,29 +36750,35 @@ public override void Validate() } } - public TieredWithProrationConfig() { } + public PricePriceTieredWithProrationTieredWithProrationConfig() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) - : base(tieredWithProrationConfig) { } + public PricePriceTieredWithProrationTieredWithProrationConfig( + PricePriceTieredWithProrationTieredWithProrationConfig pricePriceTieredWithProrationTieredWithProrationConfig + ) + : base(pricePriceTieredWithProrationTieredWithProrationConfig) { } #pragma warning restore CS8618 - public TieredWithProrationConfig(IReadOnlyDictionary rawData) + public PricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) + PricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProrationConfig FromRawUnchecked( + /// + public static PricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4491,28 +36786,34 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public TieredWithProrationConfig(IReadOnlyList tiers) + public PricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) : this() { this.Tiers = tiers; } } -class TieredWithProrationConfigFromRaw : IFromRawJson +class PricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson { /// - public TieredWithProrationConfig FromRawUnchecked( + public PricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => PricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tiered with proration tier /// [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + PricePriceTieredWithProrationTieredWithProrationConfigTier, + PricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) )] -public sealed record class TieredWithProrationConfigTier : JsonModel +public sealed record class PricePriceTieredWithProrationTieredWithProrationConfigTier : JsonModel { /// /// Inclusive tier starting value @@ -4547,31 +36848,35 @@ public override void Validate() _ = this.UnitAmount; } - public TieredWithProrationConfigTier() { } + public PricePriceTieredWithProrationTieredWithProrationConfigTier() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public TieredWithProrationConfigTier( - TieredWithProrationConfigTier tieredWithProrationConfigTier + public PricePriceTieredWithProrationTieredWithProrationConfigTier( + PricePriceTieredWithProrationTieredWithProrationConfigTier pricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(tieredWithProrationConfigTier) { } + : base(pricePriceTieredWithProrationTieredWithProrationConfigTier) { } #pragma warning restore CS8618 - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + public PricePriceTieredWithProrationTieredWithProrationConfigTier( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfigTier(FrozenDictionary rawData) + PricePriceTieredWithProrationTieredWithProrationConfigTier( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProrationConfigTier FromRawUnchecked( + /// + public static PricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4579,16 +36884,17 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw : IFromRawJson +class PricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public TieredWithProrationConfigTier FromRawUnchecked( + public PricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => PricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceTieredWithProrationConversionRateConfigConverter))] +public record class PricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4605,7 +36911,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public PricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -4614,7 +36920,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public PricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -4623,7 +36929,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public PricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -4705,7 +37011,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of PricePriceTieredWithProrationConversionRateConfig" ); } } @@ -4741,16 +37047,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of PricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator TieredWithProrationConversionRateConfig( + public static implicit operator PricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator TieredWithProrationConversionRateConfig( + public static implicit operator PricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4769,13 +37075,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of PricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + public virtual bool Equals(PricePriceTieredWithProrationConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -4802,10 +37108,10 @@ int VariantIndex() } } -sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class PricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override TieredWithProrationConversionRateConfig? Read( + public override PricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4870,14 +37176,14 @@ JsonSerializerOptions options } default: { - return new TieredWithProrationConversionRateConfig(element); + return new PricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - TieredWithProrationConversionRateConfig value, + PricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -4886,20 +37192,23 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + PricePriceGroupedWithMinMaxThresholds, + PricePriceGroupedWithMinMaxThresholdsFromRaw + >) )] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +public sealed record class PricePriceGroupedWithMinMaxThresholds : 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); } @@ -4908,12 +37217,12 @@ public required ApiEnum Cadence /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -5018,12 +37327,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5194,18 +37503,20 @@ public override void Validate() _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public PricePriceGroupedWithMinMaxThresholds() { this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) - : base(groupedWithMinMaxThresholds) { } + public PricePriceGroupedWithMinMaxThresholds( + PricePriceGroupedWithMinMaxThresholds pricePriceGroupedWithMinMaxThresholds + ) + : base(pricePriceGroupedWithMinMaxThresholds) { } #pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public PricePriceGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -5214,14 +37525,14 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + PricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static PricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5229,19 +37540,20 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson +class PricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public GroupedWithMinMaxThresholds FromRawUnchecked( + public PricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => PricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(PricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum PricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -5251,10 +37563,10 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class PricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override GroupedWithMinMaxThresholdsCadence Read( + public override PricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5262,19 +37574,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, - "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => GroupedWithMinMaxThresholdsCadence.Custom, - _ => (GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => PricePriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => PricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => PricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => PricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => PricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => PricePriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (PricePriceGroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCadence value, + PricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -5282,12 +37594,12 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMinMaxThresholdsCadence.Annual => "annual", - GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - GroupedWithMinMaxThresholdsCadence.Custom => "custom", + PricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + PricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + PricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + PricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + PricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + PricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5302,11 +37614,12 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - GroupedWithMinMaxThresholdsConfig, - GroupedWithMinMaxThresholdsConfigFromRaw + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +public sealed record class PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : JsonModel { /// /// The event property used to group before applying thresholds @@ -5369,31 +37682,35 @@ public override void Validate() _ = this.PerUnitRate; } - public GroupedWithMinMaxThresholdsConfig() { } + public PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } #pragma warning disable CS8618 - [SetsRequiredMembers] - public GroupedWithMinMaxThresholdsConfig( - GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + [SetsRequiredMembers] + public PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig pricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(groupedWithMinMaxThresholdsConfig) { } + : base(pricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } #pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5401,16 +37718,20 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson +class PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class PricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5427,7 +37748,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5436,7 +37757,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5445,7 +37766,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -5527,7 +37848,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -5563,16 +37884,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5591,13 +37912,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + public virtual bool Equals(PricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -5624,10 +37945,10 @@ int VariantIndex() } } -sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class PricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override PricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5692,14 +38013,14 @@ JsonSerializerOptions options } default: { - return new GroupedWithMinMaxThresholdsConversionRateConfig(element); + return new PricePriceGroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsConversionRateConfig value, + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -5708,20 +38029,23 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + PricePriceCumulativeGroupedAllocation, + PricePriceCumulativeGroupedAllocationFromRaw + >) )] -public sealed record class CumulativeGroupedAllocation : JsonModel +public sealed record class PricePriceCumulativeGroupedAllocation : 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); } @@ -5730,12 +38054,12 @@ public required ApiEnum Cadence /// /// Configuration for cumulative_grouped_allocation pricing /// - public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -5840,12 +38164,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public PricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6016,18 +38340,20 @@ public override void Validate() _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public PricePriceCumulativeGroupedAllocation() { this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) - : base(cumulativeGroupedAllocation) { } + public PricePriceCumulativeGroupedAllocation( + PricePriceCumulativeGroupedAllocation pricePriceCumulativeGroupedAllocation + ) + : base(pricePriceCumulativeGroupedAllocation) { } #pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public PricePriceCumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -6036,14 +38362,14 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + PricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocation FromRawUnchecked( + /// + public static PricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6051,19 +38377,20 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw : IFromRawJson +class PricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public CumulativeGroupedAllocation FromRawUnchecked( + public PricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => PricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(PricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum PricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -6073,10 +38400,10 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class PricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override CumulativeGroupedAllocationCadence Read( + public override PricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6084,19 +38411,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, - "one_time" => CumulativeGroupedAllocationCadence.OneTime, - "custom" => CumulativeGroupedAllocationCadence.Custom, - _ => (CumulativeGroupedAllocationCadence)(-1), + "annual" => PricePriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => PricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => PricePriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => PricePriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => PricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => PricePriceCumulativeGroupedAllocationCadence.Custom, + _ => (PricePriceCumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCadence value, + PricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -6104,12 +38431,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCadence.Annual => "annual", - CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - CumulativeGroupedAllocationCadence.Monthly => "monthly", - CumulativeGroupedAllocationCadence.Quarterly => "quarterly", - CumulativeGroupedAllocationCadence.OneTime => "one_time", - CumulativeGroupedAllocationCadence.Custom => "custom", + PricePriceCumulativeGroupedAllocationCadence.Annual => "annual", + PricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + PricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + PricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + PricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + PricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6124,11 +38451,12 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedAllocationConfig, - CumulativeGroupedAllocationConfigFromRaw + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel { /// /// The overall allocation across all groups @@ -6191,31 +38519,35 @@ public override void Validate() _ = this.UnitAmount; } - public CumulativeGroupedAllocationConfig() { } + public PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public CumulativeGroupedAllocationConfig( - CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + public PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig pricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(cumulativeGroupedAllocationConfig) { } + : base(pricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } #pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6223,16 +38555,20 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +class PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public CumulativeGroupedAllocationConfig FromRawUnchecked( + public PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class PricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6249,7 +38585,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6258,7 +38594,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6267,7 +38603,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public PricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -6349,7 +38685,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -6385,16 +38721,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 PricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6413,13 +38749,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 PricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + public virtual bool Equals(PricePriceCumulativeGroupedAllocationConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -6446,10 +38782,10 @@ int VariantIndex() } } -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class PricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override CumulativeGroupedAllocationConversionRateConfig? Read( + public override PricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6514,14 +38850,14 @@ JsonSerializerOptions options } default: { - return new CumulativeGroupedAllocationConversionRateConfig(element); + return new PricePriceCumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationConversionRateConfig value, + PricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -6529,18 +38865,20 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PricePricePercent : 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); } } @@ -6587,12 +38925,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required PercentConfig PercentConfig + public required PricePricePercentPercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("percent_config"); + return this._rawData.GetNotNullClass("percent_config"); } init { this._rawData.Set("percent_config", value); } } @@ -6656,12 +38994,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PercentConversionRateConfig? ConversionRateConfig + public PricePricePercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6827,18 +39165,18 @@ public override void Validate() _ = this.ReferenceID; } - public Percent() + public PricePricePercent() { this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public Percent(Percent percent) - : base(percent) { } + public PricePricePercent(PricePricePercent pricePricePercent) + : base(pricePricePercent) { } #pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public PricePricePercent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -6847,31 +39185,33 @@ public Percent(IReadOnlyDictionary rawData) #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + PricePricePercent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static PricePricePercent FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PricePricePercentFromRaw : IFromRawJson { /// - public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => - Percent.FromRawUnchecked(rawData); + public PricePricePercent FromRawUnchecked(IReadOnlyDictionary rawData) => + PricePricePercent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(PricePricePercentCadenceConverter))] +public enum PricePricePercentCadence { Annual, SemiAnnual, @@ -6881,9 +39221,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class PricePricePercentCadenceConverter : JsonConverter { - public override PercentCadence Read( + public override PricePricePercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6891,19 +39231,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PercentCadence.Annual, - "semi_annual" => PercentCadence.SemiAnnual, - "monthly" => PercentCadence.Monthly, - "quarterly" => PercentCadence.Quarterly, - "one_time" => PercentCadence.OneTime, - "custom" => PercentCadence.Custom, - _ => (PercentCadence)(-1), + "annual" => PricePricePercentCadence.Annual, + "semi_annual" => PricePricePercentCadence.SemiAnnual, + "monthly" => PricePricePercentCadence.Monthly, + "quarterly" => PricePricePercentCadence.Quarterly, + "one_time" => PricePricePercentCadence.OneTime, + "custom" => PricePricePercentCadence.Custom, + _ => (PricePricePercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PercentCadence value, + PricePricePercentCadence value, JsonSerializerOptions options ) { @@ -6911,12 +39251,12 @@ JsonSerializerOptions options writer, value switch { - PercentCadence.Annual => "annual", - PercentCadence.SemiAnnual => "semi_annual", - PercentCadence.Monthly => "monthly", - PercentCadence.Quarterly => "quarterly", - PercentCadence.OneTime => "one_time", - PercentCadence.Custom => "custom", + PricePricePercentCadence.Annual => "annual", + PricePricePercentCadence.SemiAnnual => "semi_annual", + PricePricePercentCadence.Monthly => "monthly", + PricePricePercentCadence.Quarterly => "quarterly", + PricePricePercentCadence.OneTime => "one_time", + PricePricePercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6929,8 +39269,13 @@ JsonSerializerOptions options /// /// Configuration for percent pricing /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PercentConfig : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + PricePricePercentPercentConfig, + PricePricePercentPercentConfigFromRaw + >) +)] +public sealed record class PricePricePercentPercentConfig : JsonModel { /// /// What percent of the component subtotals to charge @@ -6951,50 +39296,55 @@ public override void Validate() _ = this.Percent; } - public PercentConfig() { } + public PricePricePercentPercentConfig() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public PercentConfig(PercentConfig percentConfig) - : base(percentConfig) { } + public PricePricePercentPercentConfig( + PricePricePercentPercentConfig pricePricePercentPercentConfig + ) + : base(pricePricePercentPercentConfig) { } #pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public PricePricePercentPercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + PricePricePercentPercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static PricePricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public PercentConfig(double percent) + public PricePricePercentPercentConfig(double percent) : this() { this.Percent = percent; } } -class PercentConfigFromRaw : IFromRawJson +class PricePricePercentPercentConfigFromRaw : IFromRawJson { /// - public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - PercentConfig.FromRawUnchecked(rawData); + public PricePricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePricePercentPercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePricePercentConversionRateConfigConverter))] +public record class PricePricePercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7011,7 +39361,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public PricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7020,7 +39370,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public PricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7029,7 +39379,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public PricePricePercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -7111,7 +39461,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of PricePricePercentConversionRateConfig" ); } } @@ -7147,16 +39497,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 PricePricePercentConversionRateConfig" ), }; } - public static implicit operator PercentConversionRateConfig( + public static implicit operator PricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PercentConversionRateConfig( + public static implicit operator PricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7175,13 +39525,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 PricePricePercentConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PercentConversionRateConfig? other) => + public virtual bool Equals(PricePricePercentConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -7208,9 +39558,10 @@ int VariantIndex() } } -sealed class PercentConversionRateConfigConverter : JsonConverter +sealed class PricePricePercentConversionRateConfigConverter + : JsonConverter { - public override PercentConversionRateConfig? Read( + public override PricePricePercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7275,14 +39626,14 @@ JsonSerializerOptions options } default: { - return new PercentConversionRateConfig(element); + return new PricePricePercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PercentConversionRateConfig value, + PricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -7290,18 +39641,20 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutput : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PricePriceEventOutput : 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); } } @@ -7309,12 +39662,14 @@ public required ApiEnum Cadence /// /// Configuration for event_output pricing /// - public required EventOutputConfig EventOutputConfig + public required PricePriceEventOutputEventOutputConfig 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); } } @@ -7417,12 +39772,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public EventOutputConversionRateConfig? ConversionRateConfig + public PricePriceEventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7593,18 +39948,18 @@ public override void Validate() _ = this.ReferenceID; } - public EventOutput() + public PricePriceEventOutput() { this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - public EventOutput(EventOutput eventOutput) - : base(eventOutput) { } + public PricePriceEventOutput(PricePriceEventOutput pricePriceEventOutput) + : base(pricePriceEventOutput) { } #pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public PricePriceEventOutput(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -7613,31 +39968,34 @@ public EventOutput(IReadOnlyDictionary rawData) #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + PricePriceEventOutput(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static PricePriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputFromRaw : IFromRawJson +class PricePriceEventOutputFromRaw : IFromRawJson { /// - public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutput.FromRawUnchecked(rawData); + public PricePriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePriceEventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(PricePriceEventOutputCadenceConverter))] +public enum PricePriceEventOutputCadence { Annual, SemiAnnual, @@ -7647,9 +40005,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter : JsonConverter +sealed class PricePriceEventOutputCadenceConverter : JsonConverter { - public override EventOutputCadence Read( + public override PricePriceEventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7657,19 +40015,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => EventOutputCadence.Annual, - "semi_annual" => EventOutputCadence.SemiAnnual, - "monthly" => EventOutputCadence.Monthly, - "quarterly" => EventOutputCadence.Quarterly, - "one_time" => EventOutputCadence.OneTime, - "custom" => EventOutputCadence.Custom, - _ => (EventOutputCadence)(-1), + "annual" => PricePriceEventOutputCadence.Annual, + "semi_annual" => PricePriceEventOutputCadence.SemiAnnual, + "monthly" => PricePriceEventOutputCadence.Monthly, + "quarterly" => PricePriceEventOutputCadence.Quarterly, + "one_time" => PricePriceEventOutputCadence.OneTime, + "custom" => PricePriceEventOutputCadence.Custom, + _ => (PricePriceEventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - EventOutputCadence value, + PricePriceEventOutputCadence value, JsonSerializerOptions options ) { @@ -7677,12 +40035,12 @@ JsonSerializerOptions options writer, value switch { - EventOutputCadence.Annual => "annual", - EventOutputCadence.SemiAnnual => "semi_annual", - EventOutputCadence.Monthly => "monthly", - EventOutputCadence.Quarterly => "quarterly", - EventOutputCadence.OneTime => "one_time", - EventOutputCadence.Custom => "custom", + PricePriceEventOutputCadence.Annual => "annual", + PricePriceEventOutputCadence.SemiAnnual => "semi_annual", + PricePriceEventOutputCadence.Monthly => "monthly", + PricePriceEventOutputCadence.Quarterly => "quarterly", + PricePriceEventOutputCadence.OneTime => "one_time", + PricePriceEventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7695,8 +40053,13 @@ JsonSerializerOptions options /// /// Configuration for event_output pricing /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class EventOutputConfig : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + PricePriceEventOutputEventOutputConfig, + PricePriceEventOutputEventOutputConfigFromRaw + >) +)] +public sealed record class PricePriceEventOutputEventOutputConfig : JsonModel { /// /// The key in the event data to extract the unit rate from. @@ -7748,29 +40111,31 @@ public override void Validate() _ = this.GroupingKey; } - public EventOutputConfig() { } + public PricePriceEventOutputEventOutputConfig() { } #pragma warning disable CS8618 [SetsRequiredMembers] - public EventOutputConfig(EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } + public PricePriceEventOutputEventOutputConfig( + PricePriceEventOutputEventOutputConfig pricePriceEventOutputEventOutputConfig + ) + : base(pricePriceEventOutputEventOutputConfig) { } #pragma warning restore CS8618 - public EventOutputConfig(IReadOnlyDictionary rawData) + public PricePriceEventOutputEventOutputConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + PricePriceEventOutputEventOutputConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static EventOutputConfig FromRawUnchecked( + /// + public static PricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7778,22 +40143,24 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) + public PricePriceEventOutputEventOutputConfig(string unitRatingKey) : this() { this.UnitRatingKey = unitRatingKey; } } -class EventOutputConfigFromRaw : IFromRawJson +class PricePriceEventOutputEventOutputConfigFromRaw + : IFromRawJson { /// - public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - EventOutputConfig.FromRawUnchecked(rawData); + public PricePriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePriceEventOutputEventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceEventOutputConversionRateConfigConverter))] +public record class PricePriceEventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7810,7 +40177,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public PricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7819,7 +40186,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public PricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7828,7 +40195,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public PricePriceEventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -7910,7 +40277,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of PricePriceEventOutputConversionRateConfig" ); } } @@ -7946,16 +40313,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of PricePriceEventOutputConversionRateConfig" ), }; } - public static implicit operator EventOutputConversionRateConfig( + public static implicit operator PricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator EventOutputConversionRateConfig( + public static implicit operator PricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7974,13 +40341,13 @@ 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 PricePriceEventOutputConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(EventOutputConversionRateConfig? other) => + public virtual bool Equals(PricePriceEventOutputConversionRateConfig? other) => other != null && this.VariantIndex() == other.VariantIndex() && JsonElement.DeepEquals(this.Json, other.Json); @@ -8007,10 +40374,10 @@ int VariantIndex() } } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class PricePriceEventOutputConversionRateConfigConverter + : JsonConverter { - public override EventOutputConversionRateConfig? Read( + public override PricePriceEventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8075,14 +40442,14 @@ JsonSerializerOptions options } default: { - return new EventOutputConversionRateConfig(element); + return new PricePriceEventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - EventOutputConversionRateConfig value, + PricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Services/Customers/Credits/ILedgerService.cs b/src/Orb/Services/Customers/Credits/ILedgerService.cs index 8de37cfa5..3f80b8361 100644 --- a/src/Orb/Services/Customers/Credits/ILedgerService.cs +++ b/src/Orb/Services/Customers/Credits/ILedgerService.cs @@ -150,11 +150,13 @@ Task List( /// in the body of this request, Orb will also generate a one-off invoice for /// the customer for the credits pre-purchase. Note that you _must_ provide the /// `per_unit_cost_basis`, since the total charges on the invoice are calculated - /// by multiplying the cost basis with the number of credit units added. * if - /// `per_unit_cost_basis` is greater than zero, an invoice will be generated - /// and `invoice_settings` must be included * if `invoice_settings` is passed, - /// one of either `custom_due_date` or `net_terms` is required to determine the - /// due date + /// by multiplying the cost basis with the number of credit units added. If you + /// invoice or handle payment of credits outside of Orb (i.e. marketplace customers), + /// set `mark_as_paid` in the `invoice_settings` to `true` to prevent duplicate + /// invoicing effects. * if `per_unit_cost_basis` is greater than zero, an invoice + /// will be generated and `invoice_settings` must be included * if `invoice_settings` + /// is passed, one of either `custom_due_date` or `net_terms` is required to determine + /// the due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic @@ -252,11 +254,13 @@ Task CreateEntry( /// in the body of this request, Orb will also generate a one-off invoice for /// the customer for the credits pre-purchase. Note that you _must_ provide the /// `per_unit_cost_basis`, since the total charges on the invoice are calculated - /// by multiplying the cost basis with the number of credit units added. * if - /// `per_unit_cost_basis` is greater than zero, an invoice will be generated - /// and `invoice_settings` must be included * if `invoice_settings` is passed, - /// one of either `custom_due_date` or `net_terms` is required to determine the - /// due date + /// by multiplying the cost basis with the number of credit units added. If you + /// invoice or handle payment of credits outside of Orb (i.e. marketplace customers), + /// set `mark_as_paid` in the `invoice_settings` to `true` to prevent duplicate + /// invoicing effects. * if `per_unit_cost_basis` is greater than zero, an invoice + /// will be generated and `invoice_settings` must be included * if `invoice_settings` + /// is passed, one of either `custom_due_date` or `net_terms` is required to determine + /// the due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic From 3ca920e9721e19351676f45a5318770c5442efca Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:52:10 +0000 Subject: [PATCH 37/39] chore(test): do not count install time for mock server timeout --- scripts/mock | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/mock b/scripts/mock index 0b28f6ea2..bcf3b392b 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then + # Pre-install the package so the download doesn't eat into the startup timeout + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - # Wait for server to come online + # Wait for server to come online (max 30s) echo -n "Waiting for server" + attempts=0 while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + attempts=$((attempts + 1)) + if [ "$attempts" -ge 300 ]; then + echo + echo "Timed out waiting for Prism server to start" + cat .prism.log + exit 1 + fi echo -n "." sleep 0.1 done From cf2dd828ae62d185b5f9464d40e420fc3d9b33e3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:26:51 +0000 Subject: [PATCH 38/39] feat(api): api update --- .stats.yml | 4 ++-- .../Models/Customers/CustomerUpdateByExternalIDParams.cs | 3 ++- src/Orb/Models/Customers/CustomerUpdateParams.cs | 8 +++++--- src/Orb/Services/ICustomerService.cs | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 95afb0ace..e3a4be03b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 139 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-dafe9f726a47bdf7e506af8f10c6abcf4321dcc58106ce2b806a918778dfe2be.yml -openapi_spec_hash: 8e9827f2e8818d011e6afb203adb825f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-87e16688d40cde735bc36efd40d8c12a7918919b18268d9c40b46d0cdf2f6251.yml +openapi_spec_hash: 83f1f5a6fa7a07db4af09426232d0786 config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index b946455d7..b1c1cb443 100644 --- a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs @@ -107,7 +107,8 @@ public AddressInput? BillingAddress /// /// An ISO 4217 currency string used for the customer's invoices and balance. - /// If not set at creation time, will be set at subscription creation time. + /// This can only be set if the customer does not already have a currency configured. + /// If not set at creation or update time, it will be set at subscription creation time. /// public string? Currency { diff --git a/src/Orb/Models/Customers/CustomerUpdateParams.cs b/src/Orb/Models/Customers/CustomerUpdateParams.cs index b83718d6b..03072a599 100644 --- a/src/Orb/Models/Customers/CustomerUpdateParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateParams.cs @@ -15,8 +15,9 @@ namespace Orb.Models.Customers; /// /// This endpoint can be used to update the `payment_provider`, `payment_provider_id`, /// `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. +/// `billing_address`, `additional_emails`, and `currency` of an existing customer. +/// `currency` can only be set if it has not already been set on the 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 @@ -108,7 +109,8 @@ public AddressInput? BillingAddress /// /// An ISO 4217 currency string used for the customer's invoices and balance. - /// If not set at creation time, will be set at subscription creation time. + /// This can only be set if the customer does not already have a currency configured. + /// If not set at creation or update time, it will be set at subscription creation time. /// public string? Currency { diff --git a/src/Orb/Services/ICustomerService.cs b/src/Orb/Services/ICustomerService.cs index 7d1f14dd7..c481d392e 100644 --- a/src/Orb/Services/ICustomerService.cs +++ b/src/Orb/Services/ICustomerService.cs @@ -68,8 +68,9 @@ Task Create( /// /// This endpoint can be used to update the `payment_provider`, `payment_provider_id`, /// `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. + /// `shipping_address`, `billing_address`, `additional_emails`, and `currency` + /// of an existing customer. `currency` can only be set if it has not already + /// been set on the customer. Other fields on a customer are currently immutable. /// Task Update( CustomerUpdateParams parameters, From d887bba239b1c0737974156ffcabaec898b2959e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:27:42 +0000 Subject: [PATCH 39/39] release: 0.2.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 60 +++++++++++++++++++++++++++++++++++ src/Orb/Orb.csproj | 2 +- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d2ac0bdd..10f309169 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.2.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 15283c170..2db413e5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,65 @@ # Changelog +## 0.2.0 (2026-03-05) + +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 ([cf2dd82](https://github.com/orbcorp/orb-csharp/commit/cf2dd828ae62d185b5f9464d40e420fc3d9b33e3)) +* **api:** api update ([2ee5350](https://github.com/orbcorp/orb-csharp/commit/2ee5350e955b6ce5bb90932e250390c1bbd5983c)) +* **api:** api update ([5820227](https://github.com/orbcorp/orb-csharp/commit/582022798674964e95d81598f8a039df8aa57c99)) +* **api:** api update ([f26879d](https://github.com/orbcorp/orb-csharp/commit/f26879d5478ff24192dd4e4700016da4da6d879c)) +* **api:** api update ([716231c](https://github.com/orbcorp/orb-csharp/commit/716231cde616767e62affe993d4251d2897daaf2)) +* **api:** api update ([ebe83bc](https://github.com/orbcorp/orb-csharp/commit/ebe83bc63b23dd2c2f4b86005d8c50d579c5fd86)) +* **api:** api update ([5c9d8d7](https://github.com/orbcorp/orb-csharp/commit/5c9d8d785b6c75e97c0d5f08227e42e10b5da3c8)) +* **api:** api update ([50b2cb1](https://github.com/orbcorp/orb-csharp/commit/50b2cb1b1e7ca97069802de357b08a09fc60f95c)) +* **api:** api update ([830cc0c](https://github.com/orbcorp/orb-csharp/commit/830cc0c641572bcc8fdac8b7b754eb7ab10c0f5e)) +* **api:** api update ([89b717c](https://github.com/orbcorp/orb-csharp/commit/89b717cfbece7a4cf336964f84eebe2f9f9a2742)) +* **api:** api update ([2cd2dd8](https://github.com/orbcorp/orb-csharp/commit/2cd2dd8f519176f3618044ca6d4641e678af001b)) +* **api:** api update ([d8f27e8](https://github.com/orbcorp/orb-csharp/commit/d8f27e8e10dc99f7d6e51186171181a05a59547d)) +* **api:** api update ([3bd6cd6](https://github.com/orbcorp/orb-csharp/commit/3bd6cd6413b421ff644eee7f195e6fe0af47c56c)) +* **api:** manual updates ([dba544b](https://github.com/orbcorp/orb-csharp/commit/dba544be21d0115fd6ee8b3399fde64b16bcc3f8)) +* **client:** add `ToString` and `Equals` methods ([fed62bb](https://github.com/orbcorp/orb-csharp/commit/fed62bbc34caf8266c8c6b7a6646754677d45637)) +* **client:** add `ToString` to `ApiEnum` ([551d3d9](https://github.com/orbcorp/orb-csharp/commit/551d3d983edbc2dd99c0143b2779146fa00ae80f)) +* **client:** add equality and tostring for multipart data ([4116c95](https://github.com/orbcorp/orb-csharp/commit/4116c95ff4635a27f7e5132a3a17c413f4853efc)) +* **client:** add Equals and ToString to params ([8a87021](https://github.com/orbcorp/orb-csharp/commit/8a870218bc1eebf9e4430ed69fedc206e7b9f25c)) + + +### Bug Fixes + +* **client:** handle unions containing unknown types properly ([bb13041](https://github.com/orbcorp/orb-csharp/commit/bb13041f80e071a51a8aa845c2a5b2e720e4cd75)) +* **client:** improve behaviour for comma-delimited binary content in multipart requests ([ab0951f](https://github.com/orbcorp/orb-csharp/commit/ab0951f3e4a8d9334991eb1c4cb5ca6d43039f10)) +* **client:** improve union equality method ([5635581](https://github.com/orbcorp/orb-csharp/commit/563558107f3fa7d5e947ecf758875794c3e04dff)) + + +### Chores + +* change visibility of QueryString() and AddDefaultHeaders ([3f5afb6](https://github.com/orbcorp/orb-csharp/commit/3f5afb6e4e6d0c32a52e82c68c219391a09a0313)) +* **docs:** add missing descriptions ([e99472a](https://github.com/orbcorp/orb-csharp/commit/e99472a25dbbc10db210c0f54234fc5c2a26b25e)) +* **docs:** add proxy documentation to readme ([e4ce03d](https://github.com/orbcorp/orb-csharp/commit/e4ce03dc208398d10aa351959e9b9cf8d679672d)) +* **docs:** add undocumented parameters to readme ([c984acb](https://github.com/orbcorp/orb-csharp/commit/c984acb5f59fb3935e80abe786a1634465e862fe)) +* **internal:** add copy constructor tests ([9c7927a](https://github.com/orbcorp/orb-csharp/commit/9c7927a2079895ffcd40cc12611748f7b61bad02)) +* **internal:** codegen related update ([0273d50](https://github.com/orbcorp/orb-csharp/commit/0273d508b173a0b758832ff31ea2ce0cd0b6f5e5)) +* **internal:** codegen related update ([2bc3e43](https://github.com/orbcorp/orb-csharp/commit/2bc3e436b724ff58d3191ea1c4632be595a9e5f5)) +* **internal:** ignore stainless-internal artifacts ([f9055f0](https://github.com/orbcorp/orb-csharp/commit/f9055f0118384c77b1ef687b756e5a49f3f417dc)) +* **internal:** improve HttpResponse qualification ([2a92abb](https://github.com/orbcorp/orb-csharp/commit/2a92abb2b86492e4018b9c8fa5d75ad9486d55fc)) +* **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)) +* **test:** do not count install time for mock server timeout ([3ca920e](https://github.com/orbcorp/orb-csharp/commit/3ca920e9721e19351676f45a5318770c5442efca)) +* **tests:** add tests for retry logic ([e90a3c6](https://github.com/orbcorp/orb-csharp/commit/e90a3c65eb8c36a7016a1673f3afd3bfb04487bf)) +* update mock server docs ([72cfd07](https://github.com/orbcorp/orb-csharp/commit/72cfd078f36c6087b0ce6c30037dd2fe2d9d1d7d)) + + +### Documentation + +* remove typo in README.md ([5c40cf7](https://github.com/orbcorp/orb-csharp/commit/5c40cf77147cf374d8df1cf69f593ede2966ba9d)) + + +### Refactors + +* **internal:** default headers ([a198566](https://github.com/orbcorp/orb-csharp/commit/a198566976ed1faab7db589e8755162e567ee70f)) + ## 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/Orb.csproj b/src/Orb/Orb.csproj index 9722a9eb4..f2cc47b80 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